Skip to content

Multi-graph support with GraphManager and FROM clause#6

Merged
dylanbstorey merged 5 commits intomainfrom
feature/multi-graph-support
Jan 4, 2026
Merged

Multi-graph support with GraphManager and FROM clause#6
dylanbstorey merged 5 commits intomainfrom
feature/multi-graph-support

Conversation

@dylanbstorey
Copy link
Contributor

Summary

  • Adds complete multi-graph functionality for querying across multiple graph databases using SQLite ATTACH
  • Implements FROM clause in MATCH patterns (e.g., MATCH (n:Person) FROM social)
  • Adds graph() function to identify which graph a node comes from
  • Creates GraphManager class/struct for Python and Rust bindings

Features

Core

  • FROM clause support in MATCH patterns
  • Table prefixing for cross-graph property access
  • Variable tracking with graph association
  • graph() function for node source identification

Python Bindings

  • GraphManager class with list(), create(), open(), drop(), query(), query_sql()
  • graphs() factory function with context manager support
  • 22 tests covering all functionality

Rust Bindings

  • GraphManager struct with similar API
  • New error types: GraphExists, GraphNotFound
  • Graph::open_with_extension() method
  • 7 unit tests

Documentation

  • New how-to guide: "Working with Multiple Graphs"
  • Updated Python and Rust API references

Example Usage

from graphqlite import graphs

with graphs("./data") as gm:
    social = gm.create("social")
    social.upsert_node("alice", {"name": "Alice"}, "Person")
    
    # Cross-graph query
    result = gm.query(
        "MATCH (n:Person) FROM social RETURN n.name, graph(n) AS source",
        graphs=["social"]
    )

Test plan

  • Unit tests pass (753 C tests)
  • Python GraphManager tests pass (22 tests)
  • Rust GraphManager tests pass (7 tests)
  • Functional multi-graph tests pass

Dylan Storey added 5 commits January 3, 2026 10:39
- Update GQLITE-I-0022 with refined use cases and implementation plan
- Decompose into 6 tasks covering parser, AST, transform, bindings, and docs
- Architecture: FROM clause in C extension, GraphManager in bindings
- Add from_graph_opt grammar rule to cypher_gram.y
- Add from_graph field to cypher_match AST struct
- Update make_cypher_match to accept graph name parameter
- Add memory cleanup for from_graph in ast_node_free
- Update AST print function to show FROM clause
- Add CUnit tests for FROM clause parsing

Syntax: MATCH (n:Person) FROM graph_name WHERE ...

The FROM clause specifies which graph to query, enabling future
multi-graph support via SQLite ATTACH. The transform layer will
prefix table references based on from_graph value.
Add complete multi-graph functionality for querying across multiple
graph databases using SQLite ATTACH:

Core features:
- FROM clause in MATCH patterns (e.g., MATCH (n) FROM social)
- Table prefixing for cross-graph property access
- graph() function to identify node source graph
- Variable tracking with graph association

Python bindings:
- GraphManager class for managing multiple graphs
- graphs() factory function with context manager support
- Cross-graph query() and query_sql() methods
- 22 tests for multi-graph functionality

Rust bindings:
- GraphManager struct with similar API
- New error types: GraphExists, GraphNotFound
- Graph::open_with_extension() method
- 7 unit tests

Documentation:
- New how-to guide for multi-graph workflows
- Updated Python and Rust API references
- Use is_some_and() instead of map_or() for clippy
- Use relative path for test_other_graph.db (Windows has no /tmp)
Adds 80+ new integration tests covering:
- String functions: toUpper, toLower, trim, ltrim, rtrim, substring, replace, reverse, left, right, split
- Math functions: abs, ceil, floor, round, sqrt, sign, rand
- List functions: size, head, tail, last, range
- UNION and UNION ALL queries
- WITH clause with filtering, aggregation, ORDER BY/LIMIT
- CASE expressions (simple and generic forms)
- COALESCE function and IS NULL/IS NOT NULL predicates
- Type conversion functions: toString, toInteger, toFloat, toBoolean
- EXISTS predicate for property checks
- Multiple labels (create and match)
- OPTIONAL MATCH with and without matching results
- UNWIND clause with lists, CREATE, and range()
- GraphManager: create, open, drop, list, query, cross-graph queries

This brings Rust test coverage to parity with the Python test suite.
@dylanbstorey dylanbstorey force-pushed the feature/multi-graph-support branch from 3218b0b to 1852184 Compare January 4, 2026 19:17
@dylanbstorey dylanbstorey merged commit a63b631 into main Jan 4, 2026
4 checks passed
@dylanbstorey dylanbstorey deleted the feature/multi-graph-support branch January 4, 2026 19:19
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