Repository navigation
feat(cypher): run the official ldbc ic queries as opencypher text - #2
Merged
Merged
Conversation
…erred labels Run more of the official LDBC IC Cypher unmodified: node comparison and IN on ids, collect(node) and UNWIND back to nodes, IN over any list expression, chained comparisons, inline properties that read variables, labels inferred from relationship endpoints, mixed-type list literals, aggregates nested in expressions, and $parameters on CypherEngine.
Predicates as values (path IS NULL, NOT (pattern) AS isNew), map literals whose node values keep their properties, value.field on maps and temporal values, head/toInteger/toFloat/date/datetime and duration.inSeconds, and collect() in the order of a preceding WITH ... ORDER BY.
[x IN list WHERE p | v] unnests each row's list with positions (keeping rows whose list is empty), evaluates the predicate (pattern predicates included) and value, and collects back in order. [(a)-[:R]->(b) WHERE p | v] collects per binding of the row's variables, like an OPTIONAL MATCH, and is [] without matches.
… rows Each mark or comprehension planned its seed from the rows with the previous ones already joined on, so k of them in one projection copied the input 2^k times. Seeding all of them from the rows the projection or WHERE started from keeps the copies linear: LDBC IC14 drops from 641 to 225 physical operators and from 188 to 62 ms.
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
lance-csr 0.1.0 could answer all 14 LDBC Interactive complex (IC) queries, but only through hand-written ports that avoided syntax it lacked. This PR implements that syntax so the official IC Cypher runs as written. Features follow openCypher's standardisation scope rather than one vendor's dialect.
13 of the 14 queries now run from the unmodified official text (as adapted to the SF1 schema by ldbc-suite-test). IC14's text uses
reduce(), which the scope excludes, so it runs as a port built only from in-scope constructs (UNWIND,range,nodes(path)[i], pattern comprehensions,sum).What changed
Queries and parameters
CypherEngine.execute,execute_batchesandexplaintakeparamsfor$nameparameters, includingdatetimeanddatevalues.a < b <= cmeansa < b AND b <= c.(t:Tag {id: tagId}).(friend)<-[:postHasCreator]-(post)knowspostis a Post.Nodes and lists as values
a = b,a IN [x, y],count(DISTINCT a),uni IS NULLandpath IS NULLbehave as in Cypher.collect(node)builds a list of nodes, andUNWINDof such a list gives nodes again.x IN listworks for any list expression, not only literals.Expressions
NOT (a)-[:knows]-(b) AS isNew), map literals (a node inside a map keeps its properties), andvalue.fieldon maps and dates (latestLike.msg.ID,birthday.month).head,toInteger,toFloat,date,datetimeandduration.inSeconds. List literals that mix types become lists of strings, since Arrow lists hold one type.head(collect(...)).collectof nothing gives[], andcollectkeeps the order of a precedingWITH ... ORDER BY.[x IN list WHERE p | v], including pattern predicates on the element, and pattern comprehensions[(a)-[:R]->(b) WHERE p | v].Scoping fixes
WITH, as the planner already did.WITHmay start at a node no earlier clause bound.WITHnow plans.Planning
Validation
cargo test --workspacepasses, andcargo clippy --workspace --all-targets -- -D warningsandcargo fmt --checkare clean.*0..alternation unrolls into 20 branches, and planning them dominates its run time.[1, 2, 3]still parse as float vectors (the inherited vector-search syntax).🤖 Generated with Claude Code