Update Cypher Function Translations - BED-8261#77
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (27)
WalkthroughThis PR adds support for Cypher path functions ( ChangesCore Cypher Path Functions & Schema Foundation
Expression Translation & Type Hinting
Function Translation for Labels, Type, & Collect
Path Composite Field Resolution
SQL Fixtures & Integration Tests
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cypher/Cypher` Syntax Support.md:
- Around line 248-250: The fenced code blocks containing Cypher examples (e.g.,
the snippets starting with "match p = (a)-[*1..]->(b) return relationships(p)",
the longer "match p = (a)-[*1..]->(b) where none(r in relationships(p) where
startNode(r).name = 'blocked') return p", and "match ()-[r]->() return
endNode(r)") are missing language identifiers and trigger MD040; update each
triple-backtick fence to include the "cypher" language tag (```cypher) so the
examples are properly tagged for syntax highlighting and linting.
In `@cypher/models/pgsql/translate/function.go`:
- Around line 56-67: The error message in prepareCollectExpression is misleading
because it prints functionName where the missing argument identifier should be;
update the fmt.Errorf call in the branch handling unwrapParenthetical ->
pgsql.Identifier to include the actual identifier (typedArgument) and keep
functionName for context (e.g., "binding not found for collect function argument
<identifier> (function: <functionName>)"); locate this in
prepareCollectExpression near the Scope.Lookup(...) check and adjust the error
string accordingly so it surfaces the real unbound argument and the function
name.
In `@cypher/models/pgsql/translate/hinting.go`:
- Around line 185-201: In literalKindID add a defensive length check before
accessing kindIDs[0]: after calling kindMapper.MapKinds(kinds) verify
len(kindIDs) > 0 and if it's zero return pgsql.Literal{}, false, nil so the
caller treats it as "not converted" rather than panicking; keep existing error
returns for MapKinds and AsKinds unchanged and only add this guard before
constructing the pgsql.NewLiteral.
In `@integration/testdata/cases/aggregation.json`:
- Around line 29-33: The test case "return the size of collected labels lists"
currently uses a brittle exact_int: 3 assertion; change the assertion to a
lower-bound style (e.g., replace the "assert": {"exact_int": 3} with a minimum
assertion such as {"min_int": 3} or the project's equivalent "gte"/"min"
assertion) so the test asserts at least 3 results instead of an exact
cardinality and stays robust as the base dataset grows; update only the
assertion object for the case with cypher "MATCH (n) WITH collect(labels(n)) as
label_sets RETURN size(label_sets)" to use the project's lower-bound assertion
keyword.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8c790b28-94c2-4b27-8c30-df734396843d
📒 Files selected for processing (26)
cypher/Cypher Syntax Support.mdcypher/models/cypher/functions.gocypher/models/pgsql/functions.gocypher/models/pgsql/model.gocypher/models/pgsql/pgtypes.gocypher/models/pgsql/test/translation_cases/multipart.sqlcypher/models/pgsql/test/translation_cases/nodes.sqlcypher/models/pgsql/test/translation_cases/scalar_aggregation.sqlcypher/models/pgsql/test/translation_cases/shortest_paths.sqlcypher/models/pgsql/test/translation_cases/stepwise_traversal.sqlcypher/models/pgsql/test/translation_cases/unwind.sqlcypher/models/pgsql/test/translation_test.gocypher/models/pgsql/translate/expression.gocypher/models/pgsql/translate/function.gocypher/models/pgsql/translate/hinting.gocypher/models/pgsql/translate/path_functions.gocypher/models/pgsql/translate/projection.gocypher/models/pgsql/translate/quantifiers.gocypher/models/pgsql/translate/with.godrivers/pg/query/sql/schema_down.sqldrivers/pg/query/sql/schema_up.sqlintegration/testdata/cases/aggregation.jsonintegration/testdata/cases/nodes.jsonintegration/testdata/cases/stepwise.jsonintegration/testdata/cases/unwind_inline.jsonintegration/testdata/templates/pattern_shapes.json
| ``` | ||
| match p = (a)-[*1..]->(b) return relationships(p) | ||
| ``` |
There was a problem hiding this comment.
Add language identifiers to the new fenced Cypher examples.
These fenced blocks omit a language tag and trigger MD040 (fenced-code-language).
✏️ Suggested patch
-```
+```cypher
match p = (a)-[*1..]->(b) return relationships(p)- +cypher
match p = (a)-[*1..]->(b)
where none(r in relationships(p) where startNode(r).name = 'blocked')
return p
-```
+```cypher
match ()-[r]->() return endNode(r)
</details>
Also applies to: 256-260, 266-268
<details>
<summary>🧰 Tools</summary>
<details>
<summary>🪛 markdownlint-cli2 (0.22.1)</summary>
[warning] 248-248: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
</details>
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @cypher/Cypher Syntax Support.md around lines 248 - 250, The fenced code
blocks containing Cypher examples (e.g., the snippets starting with "match p =
(a)-[*1..]->(b) return relationships(p)", the longer "match p = (a)-[*1..]->(b)
where none(r in relationships(p) where startNode(r).name = 'blocked') return p",
and "match ()-[r]->() return endNode(r)") are missing language identifiers and
trigger MD040; update each triple-backtick fence to include the "cypher"
language tag (```cypher) so the examples are properly tagged for syntax
highlighting and linting.
</details>
<!-- fingerprinting:phantom:poseidon:hawk -->
<!-- d98c2f50 -->
<!-- This is an auto-generated comment by CodeRabbit -->
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cypher/models/pgsql/test/translation_cases/pattern_binding.sql`:
- Around line 26-27: The any(...) predicate is tautological because the CTE s1
only allows edges with kind_id in array [3,4] (EdgeKind1|EdgeKind2) while the
final WHERE checks type(r) STARTS WITH 'EdgeKind', which always holds; update
the predicate so it discriminates: either change the STARTS WITH check to an
exact match (e.g., kind_name(i0.kind_id) = 'EdgeKind1' or = 'EdgeKind2') or
adjust the allowed kinds in the s1/e0 filter (the array [3,4]::int2[]) to
include a non-matching kind, or replace the final condition with a stricter
check (e.g., kind_name(i0.kind_id) = ANY(array[...]::text[])); target the final
WHERE expression that uses kind_name(i0.kind_id)::text like 'EdgeKind%' and the
s1/e0 edge-kind filter so the predicate is not always true.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 701d5a48-f22e-4f0d-bbb8-bd5993f60ed2
📒 Files selected for processing (10)
cypher/models/pgsql/functions.gocypher/models/pgsql/test/translation_cases/pattern_binding.sqlcypher/models/pgsql/test/translation_cases/stepwise_traversal.sqlcypher/models/pgsql/translate/function.gocypher/models/pgsql/translate/hinting.godrivers/pg/query/sql/schema_down.sqldrivers/pg/query/sql/schema_up.sqlintegration/testdata/cases/aggregation.jsonintegration/testdata/cases/stepwise.jsonintegration/testdata/templates/pattern_shapes.json
✅ Files skipped from review due to trivial changes (2)
- drivers/pg/query/sql/schema_down.sql
- integration/testdata/cases/aggregation.json
🚧 Files skipped from review as they are similar to previous changes (4)
- cypher/models/pgsql/translate/function.go
- cypher/models/pgsql/translate/hinting.go
- cypher/models/pgsql/functions.go
- drivers/pg/query/sql/schema_up.sql
b28e37d to
575b815
Compare
…g value to align with expected cypher behavior
Description
Adds PostgreSQL Cypher translation support for path relationship functions, including
relationships(),startNode(), andendNode(), and fixes related Cypher semantic drift aroundlabels()andtype()handling. Also hardens PG function translation edge cases and updates fixtures/docs for the new behavior.Resolves: BED-8261
Type of Change
Testing
make test_allwithCONNECTION_STRINGset)Screenshots (if appropriate):
N/A
Driver Impact
drivers/pg)drivers/neo4j)Checklist
go.mod/go.sumare up to date if dependencies changedSummary by CodeRabbit
Release Notes
New Features
startNode()andendNode()Cypher functions for retrieving path segment endpointslabels()function support for node label filtering and aggregation operationstype()function support for relationship type retrieval and filteringTests