Skip to content

fix: terminal node constraint projection in expansion step BED-7471#39

Open
urangel wants to merge 1 commit intomainfrom
BED-7471
Open

fix: terminal node constraint projection in expansion step BED-7471#39
urangel wants to merge 1 commit intomainfrom
BED-7471

Conversation

@urangel
Copy link
Contributor

@urangel urangel commented Mar 9, 2026

Adds terminal node constraint handling to buildExpansionPatternStep and refactors buildExpansionPatternRoot to use some of the same projection and constraint builder helper functions.

Using the ad example data zip with this query:
MATCH p = (:GPO)-[:GPLink]->(:Base)-[:Contains*1..]->(t:Base) WHERE COALESCE(t.system_tags, '') CONTAINS 'admin_tier_0' RETURN p LIMIT 1000

Before fix:

image

After fix:

image

Note: There are still some edges returned that do not have the terminal node constraint upheld in this after fix image. These edges seem to be partial matches of the entire result set and are to be handled as part of this task: https://specterops.atlassian.net/browse/BED-7468

Summary by CodeRabbit

  • Refactor

    • Improved internal code organization for query translation patterns, enhancing maintainability.
  • Tests

    • Updated test cases for pattern matching and query translation scenarios to reflect refinements in path computation logic.

@urangel urangel self-assigned this Mar 9, 2026
@urangel urangel added the bug Something isn't working label Mar 9, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cf9f1d7d-06da-437b-8c4f-cc93ef3bf871

📥 Commits

Reviewing files that changed from the base of the PR and between 2838e86 and 3ba3cba.

📒 Files selected for processing (4)
  • cypher/models/pgsql/test/translation_cases/multipart.sql
  • cypher/models/pgsql/test/translation_cases/pattern_binding.sql
  • cypher/models/pgsql/test/translation_cases/pattern_expansion.sql
  • cypher/models/pgsql/translate/expansion.go
 _____________________________________________________________________________________
< All idioms must be learned. Good idioms only need to be learned once. - Alan Cooper >
 -------------------------------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ

✏️ Tip: You can disable in-progress messages and the fortune message in your review settings.

Tip

You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.

Change the reviews.profile setting to assertive to make CodeRabbit's nitpick more issues in your PRs.

Walkthrough

Changes include updates to SQL translation test cases adjusting satisfaction flag computation and edge kind constraints, and a Go refactoring extracting projection and constraint assembly logic into dedicated helper functions within the expansion pattern builder.

Changes

Cohort / File(s) Summary
SQL Translation Test Cases
cypher/models/pgsql/test/translation_cases/multipart.sql, cypher/models/pgsql/test/translation_cases/pattern_binding.sql, cypher/models/pgsql/test/translation_cases/pattern_expansion.sql
Adjustments to recursive query construction: multipart cases update CTE aliasing references; pattern_binding cases change initial edge kind constraints and recursive predicate logic; pattern_expansion cases replace static satisfaction seeds with data-driven expressions based on node kind IDs.
Expansion Pattern Builder Refactoring
cypher/models/pgsql/translate/expansion.go
Extracts projection and constraint assembly into three new helper functions: buildExpansionPrimerProjection, buildExpansionRecursiveProjection, and buildExpansionProjectionConstraints. Reduces inline duplication and centralizes terminal node satisfaction handling.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 With helpers new, the queries dance,

Seeds bloom data-driven in recursive romance,

Projections extracted, constraints refined,

Satisfaction flags recalculated, sweetly aligned,

The pattern expands, more elegant by design! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: refactoring expansion pattern building to fix terminal node constraint projection handling in the expansion step.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch BED-7471

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant