Commit ab51863
fix: rewrite denormalized node aliases to edge aliases in WITH CTE body
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>1 parent 10f4027 commit ab51863
3 files changed
Lines changed: 47 additions & 7 deletions
File tree
- src/render_plan
- tests/integration/query_patterns
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8284 | 8284 | | |
8285 | 8285 | | |
8286 | 8286 | | |
| 8287 | + | |
| 8288 | + | |
| 8289 | + | |
| 8290 | + | |
| 8291 | + | |
| 8292 | + | |
| 8293 | + | |
| 8294 | + | |
| 8295 | + | |
| 8296 | + | |
| 8297 | + | |
| 8298 | + | |
| 8299 | + | |
| 8300 | + | |
| 8301 | + | |
| 8302 | + | |
| 8303 | + | |
| 8304 | + | |
| 8305 | + | |
| 8306 | + | |
| 8307 | + | |
| 8308 | + | |
| 8309 | + | |
| 8310 | + | |
| 8311 | + | |
| 8312 | + | |
| 8313 | + | |
| 8314 | + | |
| 8315 | + | |
| 8316 | + | |
| 8317 | + | |
| 8318 | + | |
| 8319 | + | |
| 8320 | + | |
| 8321 | + | |
| 8322 | + | |
| 8323 | + | |
8287 | 8324 | | |
8288 | 8325 | | |
8289 | 8326 | | |
| |||
8438 | 8475 | | |
8439 | 8476 | | |
8440 | 8477 | | |
| 8478 | + | |
| 8479 | + | |
| 8480 | + | |
8441 | 8481 | | |
8442 | 8482 | | |
8443 | 8483 | | |
| |||
8740 | 8780 | | |
8741 | 8781 | | |
8742 | 8782 | | |
8743 | | - | |
| 8783 | + | |
| 8784 | + | |
| 8785 | + | |
| 8786 | + | |
8744 | 8787 | | |
8745 | 8788 | | |
8746 | 8789 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
817 | 817 | | |
818 | 818 | | |
819 | 819 | | |
820 | | - | |
| 820 | + | |
821 | 821 | | |
822 | 822 | | |
823 | 823 | | |
| |||
827 | 827 | | |
828 | 828 | | |
829 | 829 | | |
830 | | - | |
831 | 830 | | |
832 | 831 | | |
833 | 832 | | |
| |||
837 | 836 | | |
838 | 837 | | |
839 | 838 | | |
840 | | - | |
| 839 | + | |
841 | 840 | | |
842 | 841 | | |
843 | 842 | | |
| |||
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
836 | 836 | | |
837 | 837 | | |
838 | 838 | | |
839 | | - | |
840 | 839 | | |
841 | 840 | | |
842 | 841 | | |
| |||
846 | 845 | | |
847 | 846 | | |
848 | 847 | | |
849 | | - | |
850 | 848 | | |
851 | 849 | | |
852 | 850 | | |
| |||
856 | 854 | | |
857 | 855 | | |
858 | 856 | | |
859 | | - | |
| 857 | + | |
860 | 858 | | |
861 | 859 | | |
862 | 860 | | |
| |||
0 commit comments