Skip to content

fix(planner): plan relationships without a type when the graph has one type - #173

Open
JayPokale wants to merge 1 commit into
lance-format:mainfrom
JayPokale:fix/relationship-type-alternatives
Open

JayPokale wants to merge 1 commit into
lance-format:mainfrom
JayPokale:fix/relationship-type-alternatives

Conversation

@JayPokale

Copy link
Copy Markdown

Related: #104

A relationship pattern without a type (-[]->, -[*1..2]->) means "any relationship type" in Cypher. The logical planner passed the empty type list straight to Expand / VariableLengthExpand, so on main:

This resolves the types in LogicalPlanner::plan_path:

  • One relationship type configured: an untyped relationship uses it. This covers feat: Support variable-length relationships (*1..2) without explicit relationship types #104's example (only FOLLOWS), for single hops and variable-length paths.
  • Several types: planning fails with an explicit UnsupportedFeature error naming the configured types and asking for one, e.g. ... graph has 2 relationship types (BLOCKS, FOLLOWS); specify the type, e.g. -[:BLOCKS]->, instead of the schema error above.

Expanding over several types at once (a union of per-type expands, which also needs aligned schemas when the relationship's properties differ between types, and the same for each hop of a variable-length path) is a larger change, so I left it out; this PR does not close #104. Happy to work on that next if this direction looks right.

Tests (tests/test_relationship_types.rs, DataFusion executor):

  • with only FOLLOWS (1→2, 2→3): -[]-> from 1 returns [2], -[*1..2]-> returns [2, 3];
  • with FOLLOWS and BLOCKS: both untyped queries return the new error, and a typed -[:BLOCKS]-> still returns [3].

Both tests fail on main (with the No field named b__id error) and pass with the change.

Commands run in crates/lance-graph: cargo test (572 tests across unit, integration and doc tests pass), cargo fmt --all -- --check, cargo clippy --all-targets -- -D warnings.

I used an AI assistant (Claude) while working on this; I reviewed and tested the change.

…e type

A relationship pattern without a type, such as -[]-> or -[*1..2]->, can
follow any relationship type. The planner passed an empty type list on,
so a single hop failed with "No field named ..." and a variable-length
path with "Expand requires at least one relationship type".

When the graph configures exactly one relationship type, use it. With
several types, fail with an error that names them and asks for a type,
until expanding over several types is supported.
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.

feat: Support variable-length relationships (*1..2) without explicit relationship types

1 participant