lance-format / lance-format/lance-graph

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

Open
#104 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
179
Forks
33
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the CypherQuery.execute entry point and trace the graph-pattern validation that produces “Expand requires at least one relationship type.” Add a regression test using the supplied MATCH (a:Person)-[*1..2]->(b:Person) example, and verify it counts paths of lengths 1 through 2 without an explicit relationship type.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.