Repository navigation
feat(query): support quoted identifiers in cypher and sql - #121
Merged
Merged
Conversation
Cypher accepts backtick-quoted labels, relationship types, variables, property names and aliases, as openCypher does: a quoted name may hold spaces or other characters, may match a keyword, and writes a backtick as two. Inside GRAPH_TABLE, double quotes name identifiers as in SQL/PGQ and the surrounding SQL, so strings there need single quotes.
prrao87
marked this pull request as ready for review
November 4, 2026 01:34
Deploying lance-csr with
|
| Latest commit: |
7b035b8
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c9426a3d.lance-csr.pages.dev |
| Branch Preview URL: | https://feat-backtick-identifiers.lance-csr.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Labels, relationship types and columns whose names contain spaces or other characters, or match a keyword, can't be referenced today. Cypher identifiers only accept letters, digits and
_, so a key column such asasset idis unreachable. Applications that build queries from a schema have to skip those columns.This adds the standard quoting for each language: backticks in Cypher, as openCypher defines them, and double quotes in SQL, including inside
GRAPH_TABLEas SQL/PGQ defines them.What changed
Cypher. Any label, relationship type, variable, property name, map key or alias may be backtick-quoted:
A quoted name may contain any character and may match a keyword. Inside one, two backticks stand for one backtick. The quotes are removed while parsing, so planning, column resolution and output column names see the plain name (
asset id,a`b). The existing case-insensitive matching is unchanged. Function names and$parametersstay unquoted.SQL. The surrounding query already took double-quoted identifiers from DataFusion. Inside
GRAPH_TABLE, double quotes now name identifiers too, and""stands for one":Backticks also work inside
GRAPH_TABLE. The directgraph_table('...')call still takes Cypher text exactly as written.Query results that change
Inside a
GRAPH_TABLE (...)clause,"..."used to be a Cypher string literal. It is now an identifier, so strings there must use single quotes, as in the rest of the SQL query.WHERE a.name = "Alice"now compares against a property namedAlice. No existing test or docs example used double-quoted strings inGRAPH_TABLE.Docs
The Cypher guide gains a quoted-names section. The SQL guide now describes the
GRAPH_TABLEbody as Cypher with SQL's quoting. It also notes thatSqlEngineregisters table names in lowercase, so a quoted table name must be lowercase as well:"device type", not"Device Type".Validation
match,return,where,select), an escaped backtick, an inline property map, and SQL with double quotes in both the outer query andGRAPH_TABLE. A unit test covers theGRAPH_TABLEquote rewrite, including"", backticks inside double quotes, and a"inside a single-quoted string.cargo test --workspace,cargo clippy --workspace --all-targets -- -D warnings,cargo fmt --check, the Python suite (1700 passed), ruff, pyright, typos and the strict docs build all pass.mainafter fix(query): support bound string predicates and untyped relationships across labels #120 merged (it also changes the parser). On the combined code, Rust tests, Clippy and the Python suite (1706 passed) all pass.🤖 Generated with Claude Code