fix: denormalized node alias rewriting in WITH CTE body#224
Merged
Conversation
When a denormalized schema embeds node properties in the edge table, the FROM clause aliases the table with the edge alias (e.g., `flights AS r`). Property access on denormalized nodes (e.g., `a.city`) must be rewritten to use the edge alias (`r.OriginCityName`). The property name mapping was already handled by `rewrite_expression_with_property_mapping`, but the table alias was not being rewritten in the WITH CTE rendering path. Add `rewrite_denormalized_aliases_in_expr()` that uses `get_properties_with_table_alias()` to detect denormalized nodes and rewrite their aliases in SELECT items and GROUP BY expressions during CTE body construction. Fixes 3 denormalized WITH aggregation integration tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
genezhang
added a commit
that referenced
this pull request
Mar 13, 2026
Enhance resolve_denormalized_property_in_expr() to handle both table alias rewriting AND property name mapping using get_properties_with_table_alias(). Key improvements: - Property name resolution now correctly distinguishes from_node vs to_node (e.g., a.city → r.OriginCityName, b.city → r.DestCityName) - Cross-side correction: when schema mapping maps to wrong side's column (e.g., b.city → OriginCityName), reverse-lookups through node schema's from_properties/to_properties to find the correct Cypher property name, then resolves through the correct side's denormalized mapping - Also handles CASE expressions and covers coupled schema aliases Fixes 6 more integration tests across denormalized and coupled schemas. Total: 9 tests promoted from xfail to passing (3 from PR #224 + 6 here). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6 tasks
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.
Summary
SELECT a.OriginCityNamewhen the FROM clause only hasflights AS r(noaalias exists)rewrite_denormalized_aliases_in_expr()inplan_builder_utils.rsthat detects denormalized nodes viaget_properties_with_table_alias()and rewritesa.X→r.Xin CTE SELECT and GROUP BY expressionsTest plan
🤖 Generated with Claude Code