fix(gfql/cypher): neo4j round() tie-breaking + lower/upper GQL aliases (#1673)#1677
Open
lmeyerov wants to merge 2 commits into
Open
fix(gfql/cypher): neo4j round() tie-breaking + lower/upper GQL aliases (#1673)#1677lmeyerov wants to merge 2 commits into
lmeyerov wants to merge 2 commits into
Conversation
b6bb4e6 to
197ff1e
Compare
lmeyerov
added a commit
that referenced
this pull request
Jul 2, 2026
…in _cudf_regex_prep The cuDF =~ flags commit annotated _cudf_regex_prep with "tuple[object, bool]", which mypy rejects on py3.8/3.9 (builtin generics need 3.9+/3.10+); broke the python-lint-types (3.8, 3.9) lanes on #1675/#1677. Use typing.Tuple. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
197ff1e to
3ca652e
Compare
lmeyerov
added a commit
that referenced
this pull request
Jul 2, 2026
…lane The polars-parametrized cypher tests (numeric fns, toLower, =~ parity in graphistry/tests/compute/gfql/cypher/test_lowering.py) never executed in CI: the core lane has no polars installed (importorskip -> skip) and the polars lane's fixed file list excluded the file. So the polars numeric lowerings this branch adds were CI-untested and their changed lines uncovered (coverage gate 76.9% < 80). Add the file (-k polars) to bin/test-polars.sh and the ci.yml polars coverage step (--cov-append). Moved from the stacked #1677 to here — it belongs with the lowerings it tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3ca652e to
21472b4
Compare
#1673 standards vetting) Standards re-vet vs neo4j Cypher 25 (manual + shipped parser source) and ISO GQL (opengql/grammar + neo4j GQL-conformance appendix) found one wrong-answer and one missing conformance alias in the shipped numeric/string functions: 1. round() ties DIVERGED: we used numpy/polars half-to-even (round(2.5) -> 2.0), but neo4j's documented semantics are precision 0 (and 1-arg) = ties toward +inf (round(-1.5) = -1.0, manual Ex. 8/10) and precision > 0 = ties away from zero (HALF_UP: round(-1.55, 1) = -1.6, Ex. 11). Fixed on pandas/cuDF (floor(x+0.5) / scaled HALF_UP) and polars (floor(x+0.5) for p=0; native round(mode='half_away_from_zero') for p>0 — a manual scale/divide formula picks up 1-ulp noise from polars' reassociating optimizer). Parity-tested against the manual's example values on both engines. 2. lower()/upper() added as aliases of toLower()/toUpper() — ISO GQL mandatory character-string functions (§20.24); neo4j accepts both spellings as its GQL-conformance aliases. Also records the settled `^` spec (LEFT-associative: openCypher TCK + neo4j's shipped parser both left-fold; the manual's "right to left" row is a docs bug) for the deferred re-add, and corrects the XOR note (GQL HAS XOR, GE07). 1618 tests pass; ruff + mypy clean; CHANGELOG + docs updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tive-precision decline, CI polars lane Adversarial review of the round() conformance fix (4 IMPORTANT findings): - I2/S2: replace floor(x+0.5) with a floor+frac kernel on both engines — the +0.5 addition itself rounds up when x sits 1 ulp below a tie (JDK-6430675), e.g. round(0.49999999999999994) must be 0.0 and round(0.0499…96, 1) -> 0.0 (pandas previously disagreed with polars/neo4j here). Also: scaled-overflow identity (round(1e300, 20) = 1e300, not inf), -0.0 normalized (+0.0). - I1: negative precision now declines honestly on both engines (neo4j raises; polars previously crashed with a raw OverflowError, pandas silently computed). - I3: the polars-parametrized cypher test_lowering cases never ran in CI (core lane has no polars; polars lane's file list excluded the file) — added cypher/test_lowering.py -k polars to bin/test-polars.sh + the ci.yml coverage step (--cov-append). - I4: setup.py polars extra floor >= 1.5 (round(mode=) kwarg requirement). +ulp/inf/negative-precision tests (engine-parametrized, importorskip-guarded). 1620 tests pass; ruff + mypy clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
f997217 to
31054a8
Compare
lmeyerov
added a commit
that referenced
this pull request
Jul 2, 2026
…in _cudf_regex_prep The cuDF =~ flags commit annotated _cudf_regex_prep with "tuple[object, bool]", which mypy rejects on py3.8/3.9 (builtin generics need 3.9+/3.10+); broke the python-lint-types (3.8, 3.9) lanes on #1675/#1677. Use typing.Tuple. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lmeyerov
added a commit
that referenced
this pull request
Jul 2, 2026
…lane The polars-parametrized cypher tests (numeric fns, toLower, =~ parity in graphistry/tests/compute/gfql/cypher/test_lowering.py) never executed in CI: the core lane has no polars installed (importorskip -> skip) and the polars lane's fixed file list excluded the file. So the polars numeric lowerings this branch adds were CI-untested and their changed lines uncovered (coverage gate 76.9% < 80). Add the file (-k polars) to bin/test-polars.sh and the ci.yml polars coverage step (--cov-append). Moved from the stacked #1677 to here — it belongs with the lowerings it tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
21472b4 to
ccede7e
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.
Stacked on #1675. Result of a deep standards re-vet of the #1673 dialect extensions against primary sources — the current neo4j Cypher manual, neo4j's shipped Cypher 5/25 parser source, the openCypher TCK, and the ISO-derived GQL grammar + neo4j's GQL-conformance appendix. Full findings table posted on #1673.
Fixes
1.
round()tie-breaking — was a wrong answer vs neo4j. We shipped numpy/polars half-to-even (round(2.5)→ 2.0). Neo4j's documented semantics: precision 0 (and the 1-arg form) rounds ties toward +∞ (round(-1.5)→-1.0, manual Ex. 8/10); precision > 0 rounds ties away from zero (HALF_UP:round(-1.55, 1)→-1.6, Ex. 11). Fixed on pandas/cuDF (floor(x+0.5)/ scaled HALF_UP) and polars (floor(x+0.5)for p=0; nativeround(mode="half_away_from_zero")for p>0 — a manual scale/divide formula picks up 1-ulp noise from polars' reassociating optimizer). Parity-tested on both engines against the manual's example values. (Note: the neo4j args-table "(default: UP)" contradicts its own Example 10 — docs bug; the examples are authoritative.)2.
lower()/upper()aliases added — ISO GQL mandatory §20.24 character-string functions; neo4j accepts both spellings as GQL-conformance aliases oftoLower/toUpper. A GQL-aligned dialect should too.Spec records (no code change, see #1673 addendum)
^settled as LEFT-associative for the eventual re-add: the openCypher TCK pins left (4^(3*2)^3= (4^6)^3) and neo4j's shipped parser left-foldsPow(Cypher25Parser.g4+astBinaryFold=foldLeft) — the manual's "Right to left" precedence row is a neo4j docs bug.GRAPH g = GRAPH { … }andCREATE GFQL INDEXconfirmed as documented extensions (GQL §10.1 takes graph references only; GQL has zero index DDL — neo4j's ownCREATE INDEXis likewise beyond-GQL).LIKE/BETWEENabsence from GQL re-verified hard (grammar's onlyLIKEisCREATE GRAPH TYPE … LIKE g).Tests
Neo4j-manual example values asserted on pandas and polars (
test_round_neo4j_tie_breaking,test_lower_upper_gql_aliases, updated scalar cases); 1618 tests pass across expr-parser/lowering/row-pipeline/polars suites; ruff + mypy clean. cuDF lane: the fix uses the same engine-portable pattern as floor/ceil (cuDF-native.floor()elsenp.floor); GPU parity rides the existing #1673 dgx pass.🤖 Generated with Claude Code