Skip to content

fix(cypher): make conjoined varlen WHERE predicates order-invariant (#1332)#1336

Merged
lmeyerov merged 1 commit intomasterfrom
issue-1332-where-varlen-order-sensitivity
May 7, 2026
Merged

fix(cypher): make conjoined varlen WHERE predicates order-invariant (#1332)#1336
lmeyerov merged 1 commit intomasterfrom
issue-1332-where-varlen-order-sensitivity

Conversation

@lmeyerov
Copy link
Copy Markdown
Contributor

@lmeyerov lmeyerov commented May 7, 2026

Summary

Fixes #1332: WHERE conjunctions containing variable-length pattern predicates were order-sensitive.

Root cause

ASTNormalizer._rewrite_where_pattern_predicates_to_matches() rewrote multiple positive pattern predicates into an appended MATCH clause, which could couple independent existence checks into a connected pattern shape and make AND operand order observable.

Fix

  • Keep multi-positive WHERE pattern predicates in WHERE (skip the appended-MATCH rewrite for that case)
  • Lower positive WherePatternPredicate entries directly into independent semi_apply_mark row pre-filters
  • Conjoin generated marker columns as row-level filters

Tests

Updated regression coverage in test_lowering.py:

  • Existing conjoined bounded-varlen test now checks both operand orders
  • Asserts equality across swapped-order queries
  • Corrected expected rows to the logical conjunction result for fixture: [{"id":"a"}, {"id":"b"}]

Validation

  • PYTHONPATH=. UV_CACHE_DIR=/tmp/uv-cache uv run --no-project --with pytest --with pandas python -m pytest -q graphistry/tests/compute/gfql/cypher/test_lowering.py -k "bounded_variable_length_where_pattern_predicates or conjoined_bounded_varlen_where_predicates_across_edge_types or bounded_variable_length_where_pattern_boolean_wrappers"
  • PYTHONPATH=. UV_CACHE_DIR=/tmp/uv-cache uv run --no-project --with pytest --with pandas python -m pytest -q graphistry/tests/compute/gfql/cypher/test_lowering.py -k "where_pattern_predicate"
  • ./bin/ruff.sh graphistry/compute/gfql/cypher/ast_normalizer.py graphistry/compute/gfql/cypher/lowering.py graphistry/tests/compute/gfql/cypher/test_lowering.py

Refs #1332

@lmeyerov lmeyerov merged commit 8accbb4 into master May 7, 2026
169 of 207 checks passed
@lmeyerov lmeyerov deleted the issue-1332-where-varlen-order-sensitivity branch May 7, 2026 06:53
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.

Cypher: WHERE pattern-predicate AND order sensitivity with varlen clauses

1 participant