Skip to content

feat: Allow trailing semicolons in query to be more in line with other graph systems #101

@prrao87

Description

@prrao87

Summary

For users coming from Graph databases that have CLIs or Cypher query editors (e.g., Neo4j, Kuzu, Ladybug), queries that end with ; fail to parse, even though the rest of the query is perfectly valid. Cypher parsers in well-known graph databases often allows trailing semicolons to indicate the end of a query.

Example

import pyarrow as pa
from lance_graph import GraphConfig, CypherQuery

people = pa.table({"id": [1]})
cfg = GraphConfig.builder().with_node_label("Person", "id").build()
datasets = {"Person": people}

CypherQuery("MATCH (p:Person) RETURN p.id LIMIT 1;").with_config(cfg).execute(datasets)
Traceback (most recent call last):
  File "/Users/prrao/code/graph-benchmark/lance_graph/tt.py", line 8, in <module>
    CypherQuery("MATCH (p:Person) RETURN p.id LIMIT 1;").with_config(cfg).execute(datasets)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Cypher parse error at position 36: Unexpected input after query: ;

Expected

Query executes (same behavior as without semicolon).

Actual

ValueError: Cypher parse error ... Unexpected input after query: ;

Proposal

Simple regex match and removal could work.

The user's expectation (coming from other systems) may be to mark the end of the query block with a semicolon.

However, in the future, if multiple query executions via a single call are supported that use a semicolon to separate intent. If this is intended to be supported in the future, then the regex approach may not work.

In such a case, it might make sense to handle the semicolon a bit more gracefully (like warning the user that semicolons aren't accepted as part of the query, removing it and continuing to execute it), rather than throwing an outright error.

Environment

The following environment was used to test this:

lance-graph 0.4.0
Python 3.13
macOS Tahoe 26.2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions