Skip to content

feat(gfql): native polars undirected var-length bindings (-[*1..k]-) — unblocks IC11/IC6 cross-alias WHERE#1754

Merged
lmeyerov merged 1 commit into
masterfrom
feat/gfql-samepath-crossalias-where-polars
Jul 20, 2026
Merged

feat(gfql): native polars undirected var-length bindings (-[*1..k]-) — unblocks IC11/IC6 cross-alias WHERE#1754
lmeyerov merged 1 commit into
masterfrom
feat/gfql-samepath-crossalias-where-polars

Conversation

@lmeyerov

Copy link
Copy Markdown
Contributor

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, and binding_rows_polars hard-declined every undirected varlen edge (CHANGELOG's documented "undirected bounded var-length (IC6/IC11)" residual). The cross-alias WHERE lowering itself was already native — the entanglement was the bindings materialization.

This ports the pandas oracle (_gfql_multihop_binding_rows with avoid_immediate_backtrack) for undirected -[*1..k]- with min_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) and min_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)

  • The full IC11 WHERE not(person=friend) clause is now native on polars and byte-identical to pandas (verified end-to-end).
  • My A/B on a multiplicity-heavy graph (parallel + self-loop + antiparallel edges): *1..2 WHERE NOT a=b, *1..3, no-WHERE — all match pandas exactly; out-of-scope *2..3 honest-NIEs; 0 silent-wrong.
  • Author's differential fuzz vs pandas: ~2500+ comparisons, 0 disagreements; supported shapes never silent-wrong, out-of-scope always decline.
  • 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..1 range form + cross-alias WHERE under-counts on polars (pandas 12 vs polars 6). Filed as #1753 (*1..1 is is_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

…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
lmeyerov force-pushed the feat/gfql-samepath-crossalias-where-polars branch from a76ab12 to f19f2cc Compare July 20, 2026 23:27
@lmeyerov
lmeyerov merged commit 983d2af into master Jul 20, 2026
57 checks passed
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.

1 participant