Skip to content

feat: add Lance-namespace integration for automatic table resolution#93

Closed
beinan wants to merge 1 commit into
lance-format:mainfrom
beinan:feat/lance-namespace-integration
Closed

feat: add Lance-namespace integration for automatic table resolution#93
beinan wants to merge 1 commit into
lance-format:mainfrom
beinan:feat/lance-namespace-integration

Conversation

@beinan

@beinan beinan commented Jan 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements automatic table resolution for Lance-backed graphs, enabling users to execute Cypher queries without manually managing table dictionaries. Addresses issue #90.

Changes

1. Convention-Based Schema Inference (LanceGraphStore.infer_graph_config())

  • Automatically infers graph configuration from Lance table schemas
  • Tables with single *_id field → Node tables
  • Tables with 2+ *_id fields → Relationship tables

2. Store-Based Query Execution (execute_with_store())

  • New function for executing Cypher queries with a LanceGraphStore
  • Automatic configuration resolution (YAML schema → convention-based inference)
  • Performance optimization: only loads tables required for the query
  • Avoids full dataset enumeration on cloud storage

3. Comprehensive Test Suite

  • 14 new tests in test_namespace.py
  • Covers inference, execution, and integration scenarios
  • All existing tests continue to pass (no regressions)

Usage Example

from lance_graph import CypherQuery, execute_with_store
from knowledge_graph import LanceGraphStore, KnowledgeGraphConfig

# Connect to a Lance namespace (local or cloud)
store = LanceGraphStore(KnowledgeGraphConfig.from_root("s3://my-bucket/graph-data"))

# Execute queries without manually passing table dictionaries
query = CypherQuery("MATCH (p:Person)-[:KNOWS]->(f) RETURN p.name, f.name")
result = execute_with_store(query, store)  # Automatically infers config!

Benefits

  1. Minimal code changes: Builds on existing LanceGraphStore infrastructure
  2. Backward compatible: Existing code continues to work unchanged
  3. Performance optimized: Smart table loading prevents unnecessary data reads
  4. Cloud storage ready: Works with S3/GCS via existing fsspec integration
  5. Flexible: Supports YAML schema, conventions, or explicit configuration

Test Results

  • ✅ 14/14 new tests passed
  • ✅ 33/33 existing tests passed
  • ✅ 47/47 total tests passing

🤖 Generated with Claude Code

Add convention-based schema inference and store-based query execution
to enable users to execute Cypher queries without manually managing
table dictionaries.

Features:
- LanceGraphStore.infer_graph_config(): Infer graph configuration from table schemas
- execute_with_store(): Execute queries with automatic config resolution
- Smart table loading: Only loads tables required for the query
- Supports YAML schema, convention-based inference, or explicit config
- Works with local, S3, and GCS storage via existing fsspec integration

Closes lance-format#90

Co-Authored-By: Claude <noreply@anthropic.com>
@beinan beinan closed this Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant