Skip to content

fix: expression property mappings + CTE node expansion tests#203

Merged
genezhang merged 7 commits intomainfrom
fix/xfail-bug-fixes
Mar 11, 2026
Merged

fix: expression property mappings + CTE node expansion tests#203
genezhang merged 7 commits intomainfrom
fix/xfail-bug-fixes

Conversation

@genezhang
Copy link
Copy Markdown
Owner

Summary

Two fixes from xfail triage (targets 24 of 219 remaining xfails):

  1. Expression-based property mappings (12 tests): Schema mappings like tier: "if(score >= 1000, 'gold', ...)" lost their Expression variant when resolved through map_property_to_column_with_relationship_context() (returns String). The caller wrapped the result as PropertyValue::Column, causing backtick-quoting in WHERE/GROUP BY. Fix: add map_property_to_property_value() that preserves the PropertyValue variant.

  2. WITH CTE node expansion (12 tests): Not a code bug — tests checked for a_user_id prefix but code correctly produces a.user_id dot notation. Fixed test assertions to accept both formats, removed all 12 xfail markers.

Test plan

  • cargo test — 1,575 tests pass, 0 failures
  • cargo fmt --all — clean
  • Endurance test with jemalloc: VmRSS stable at 16MB after 4M+ queries

🤖 Generated with Claude Code

genezhang and others added 6 commits March 9, 2026 18:52
Two fixes from xfail triage:

1. Expression-based property mappings (12 tests): Schema mappings like
   `tier: "if(score >= 1000, 'gold', ...)"` were losing their Expression
   variant when resolved through map_property_to_column, which returns
   String. The caller wrapped the result as PropertyValue::Column,
   causing backtick-quoting instead of expression expansion. Fix: add
   map_property_to_property_value() that preserves the PropertyValue
   variant, and use it in apply_property_mapping_to_expr().

2. WITH CTE node expansion (12 tests): Tests checked for `a_` prefix
   columns but the code correctly produces `a.` dot notation. Fixed
   test assertions to accept both formats via get_var_columns() helper,
   and removed all 12 xfail markers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
length(path), nodes(path), relationships(path) inside WITH clauses
were generating invalid SQL. Now rewritten to VLP CTE columns
(hop_count, path_nodes, path_relationships) via rewrite_expr_for_vlp.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
WITH u AS person WHERE person.name = 'Alice' was generating invalid SQL
because "person" alias doesn't exist inside the CTE body. Now rewrites
renamed aliases back to source aliases before property mapping.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Three fixes:
1. collect+unwind elimination: skip adding passthrough source variable when
   it already exists in remaining WITH items (prevented duplicate CTE columns)
2. COUNT(p) on path variable: add is_path field to TableCtx so
   is_path_variable() correctly identifies path variables registered via
   define_path() (previously returned false due to explicit_alias=true guard)
3. COUNT(p) → COUNT(*) rewriting in both rewrite_expr_for_fixed_path and
   rewrite_expr_for_vlp for path variable arguments

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The parser represents `-0.5` as `0 - 0.5` (OperatorApplicationExp), not
as a negative literal. This caused lists containing negative numbers like
`[-0.5, 0.3, 0.1]` to have all elements wrapped in toString(), breaking
cosineDistance and other numeric array functions.

Added is_literal_like() helper that recognizes the `0 - literal` pattern
as effectively a literal for the list homogeneity check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
USE `my-database` now correctly parsed. Previously only unquoted
alphanumeric/underscore/dot identifiers were supported.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses two clusters of xfail triage failures by fixing expression-based schema property mappings (preserving PropertyValue::Expression through rendering) and aligning/expanding coverage around WITH/CTE behaviors (including VLP path functions and node expansion assertions).

Changes:

  • Preserve PropertyValue variants during property mapping (Column vs Expression) via new map_property_to_property_value() / map_rel_property_to_property_value() and updated renderer mapping.
  • Improve WITH/CTE handling: rewrite renamed aliases in post-WITH WHERE clauses; support VLP path-function rewriting and COUNT(path) → COUNT(*).
  • Update and extend integration tests (Rust + Python) to remove xfails and validate the corrected SQL generation patterns.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/rust/integration/complex_feature_tests.rs Adds integration coverage for VLP path functions in WITH, alias-rename WHERE behavior, collect+unwind column dedup, and COUNT(path) rewrite.
tests/integration/test_with_cte_node_expansion.py Removes xfails and relaxes assertions to accept both a.property and a_property column naming.
src/render_plan/render_expr.rs Improves list “literal-ness” detection to treat unary-minus literals as literal-like (avoids unnecessary toString() wrapping).
src/render_plan/plan_builder_utils.rs Rewrites renamed aliases back to source aliases in WITH WHERE at logical-expr level; adds helper for alias rewriting.
src/render_plan/plan_builder_helpers.rs Preserves Expression mappings for node/relationship properties by mapping to PropertyValue when possible.
src/render_plan/plan_builder.rs Adds VLP path variable extraction for WITH, rewrites aliases in WHERE (render-expr level), and rewrites VLP path-function expressions in WITH select items.
src/render_plan/cte_generation.rs Introduces map_property_to_property_value() and map_rel_property_to_property_value() to preserve Expression mappings.
src/query_planner/plan_ctx/table_ctx.rs Adds explicit is_path tracking to reliably identify path variables.
src/query_planner/optimizer/collect_unwind_elimination.rs Avoids adding duplicate passthrough projection items during collect+unwind elimination.
src/query_planner/logical_plan/match_clause/helpers.rs Marks registered path variables explicitly in TableCtx (set_is_path(true)).
src/open_cypher_parser/use_clause.rs Extends USE clause parsing to support backtick-quoted identifiers; adds parser tests.
src/clickhouse_query_generator/to_sql_query.rs Rewrites COUNT(path_var) to COUNT(*) for both VLP and fixed-hop path rewrites.

Comment thread src/render_plan/plan_builder_helpers.rs
Comment thread src/render_plan/plan_builder.rs
Comment thread tests/rust/integration/complex_feature_tests.rs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

…path, rewrite aliases in Union branch

- get_property_from_viewscan now returns PropertyValue directly instead of
  String, preserving Expression variants for expression-based schema mappings
- Apply reverse-alias rewrite for WITH WHERE in Union/bidirectional branch
  (was only in standard path, causing unresolved aliases for bidirectional inputs)
- Make CTE duplicate-column test case-insensitive and more robust

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@genezhang genezhang merged commit c7338b2 into main Mar 11, 2026
4 checks passed
@genezhang genezhang deleted the fix/xfail-bug-fixes branch March 11, 2026 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants