Skip to content

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

@prrao87

Description

@prrao87

Summary

 -[*1..2]-> fails with “requires at least one relationship type”. In Cypher, omitting the rel type means “any relationship”.
Specifying Kleene star operators in Cypher is a natural expectation among users of graph DBs who may be coming into lance-graph, so it would be good to embrace these users with open arms.

Example

import pyarrow as pa
from lance_graph import GraphConfig, CypherQuery

people = pa.table({"id": [1, 2, 3]})
follows = pa.table({"src": [1, 2], "dst": [2, 3]})
cfg = (
    GraphConfig.builder()
    .with_node_label("Person", "id")
    .with_relationship("FOLLOWS", "src", "dst")
    .build()
)
datasets = {"Person": people, "FOLLOWS": follows}

query = "MATCH (a:Person)-[*1..2]->(b:Person) RETURN count(*)"
CypherQuery(query).with_config(cfg).execute(datasets)
Traceback (most recent call last):
  File "/Users/prrao/code/graph-benchmark/lance_graph/tt.py", line 15, in <module>
    CypherQuery(query).with_config(cfg).execute(datasets)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
ValueError: Invalid graph pattern: Expand requires at least one relationship type

Expected

Count of paths length 1..2, regardless of rel type.

Actual

ValueError: Invalid graph pattern: Expand requires at least one relationship type

Proposal

Explicit types work, e.g., (-[:FOLLOWS*1..2]->), but the any-type form is standard Cypher which users will expect when they come from other systems.

Environment

The following environment was used to test this:

lance-graph 0.4.0
Python 3.13
macOS Tahoe 26.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions