feat(gfql): native polars undirected var-length bindings (-[*1..k]-) — unblocks IC11/IC6 cross-alias WHERE#1754
Merged
Conversation
…for IC11/IC6 cross-alias WHERE binding_rows_polars now materializes the bounded UNDIRECTED variable-length bindings table for min_hops==1 (the LDBC IC11/IC6 -[*1..k]- shape), unblocking the cross-alias same-path `WHERE NOT a = b` / `a <> b` clause on polars (the WHERE lowering itself was already native; the residual was the undirected `rows(binding_ops=...)` materialization declining). Exact port of the pandas oracle `_gfql_multihop_binding_rows` (avoid_immediate_backtrack=True): a `__prev__` marker (seeded null, dtype-matched to the id column) drops immediate backtracks each hop, and the step-pair set reproduces pandas' edge multiplicity (each non-loop edge each directed orientation x2; self-loops (u,u) x2 only). Scoped to min_hops==1 where the raw-edge reconstruction provably matches pandas; min_hops 0 and >=2 decline with an honest NotImplementedError (never silent-wrong). Differential fuzz vs pandas over ~2500 random graphs (self-loops, parallel + antiparallel edges, *1..2..*1..5, all WHERE/RETURN variants): 0 disagreements; out-of-scope windows decline. Tests: parity + multiplicity/backtrack/self-loop/ string-id pins + *0..2/*2..3/*2..2 decline pins. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6dQEcjdazEnzuvuwf73ZL
lmeyerov
force-pushed
the
feat/gfql-samepath-crossalias-where-polars
branch
from
July 20, 2026 23:27
a76ab12 to
f19f2cc
Compare
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.
What
Bisecting the official LDBC IC11 on polars pinpointed a single residual: the cross-alias
WHERE not(person=friend)forced an undirected variable-length bindings table to materialize, andbinding_rows_polarshard-declined every undirected varlen edge (CHANGELOG's documented "undirected bounded var-length (IC6/IC11)" residual). The cross-aliasWHERElowering itself was already native — the entanglement was the bindings materialization.This ports the pandas oracle (
_gfql_multihop_binding_rowswithavoid_immediate_backtrack) for undirected-[*1..k]-withmin_hops == 1: a doubled-pair join with immediate-backtrack avoidance (a dtype-matched__prev__marker drops immediate backtracks each hop; Kleene null-prev kept), reproducing pandas' exact step-pair multiplicity (each non-loop edge ×2 per orientation; self-loops ×2 only) — derived by instrumenting pandas' actual step_pairs, not by reading code.min_hops == 0(*0..k) andmin_hops >= 2(*2..k) decline honestly (pandas' hop-window backward-pruning changes multiplicity there — reproducing from raw edges would be silent-wrong).Verification (independent — re-run by the reviewing agent)
WHERE not(person=friend)clause is now native on polars and byte-identical to pandas (verified end-to-end).*1..2WHERE NOT a=b,*1..3, no-WHERE — all match pandas exactly; out-of-scope*2..3honest-NIEs; 0 silent-wrong.test_engine_polars_binding_rows.py: 51 pass (independently re-run); 1151 polars tests pass. ruff clean; mypy master-baseline.Adjacent finding (filed, NOT fixed here)
While verifying, confirmed a pre-existing silent-wrong on master (independent of this PR, a different code path): undirected
*1..1range form + cross-alias WHERE under-counts on polars (pandas 12 vs polars 6). Filed as #1753 (*1..1isis_multihop=False→ the untouched single-hop binding path). Fix direction there: reproduce multiplicity or decline (cf #1748).Off master (touches
row_pipeline.py::binding_rows_polars— overlaps #1750/#1751/#1752's file; trivial rebase). Refs #1273 / the IC6/IC11 coverage push.🤖 Generated with Claude Code