Repository navigation
fix(gfql/cypher): preserve openCypher Duration components through toString + equality (#1361) - #1364
Merged
Merged
Conversation
…tring + equality (#1361) `_normalize_duration_map` (graphistry/compute/gfql/temporal_text.py) now keeps the three openCypher CIP `Duration` component groups (months, days, seconds+nanoseconds) separate through canonicalization instead of collapsing days into total nanoseconds. Behavior changes (canonical strings): - `duration({years: 12, months: 5, days: -14, hours: 16})` → `P12Y5M-14DT16H` (was `P12Y5M-13DT-8H`) - `duration({days: 1, milliseconds: -1})` → `P1DT-0.001S` (was `PT23H59M59.999S`) - `duration({...}) = duration({...})` returns `false` for two durations with equal totals but different `(days, seconds)` component shapes (was incorrectly `true` due to total-ns equivalence). Closes 3 of the 14 wrong-row cases under #1361 / #1353 item #2: expr-temporal6-6-2, expr-temporal6-6-8, expr-temporal7-6-8. The remaining 11 are tck-gfql port issues (tck-gfql#36, tck-gfql#38) deferred to that repo. The single Stockholm-1818 historical TZ case (expr-temporal2-6-5) is also out of scope here. All 25 prior duration tests + 3 new behavioral tests pass; full `graphistry/tests/compute/gfql/` = 1900 passed, no regressions. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
3 tasks done
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.
Summary
_normalize_duration_map(graphistry/compute/gfql/temporal_text.py) now keeps the three openCypher CIPDurationcomponent groups (months, days, seconds+nanoseconds) separate through canonicalization instead of collapsing days into total nanoseconds.Behavior changes (canonical strings)
duration({years: 12, months: 5, days: -14, hours: 16})→P12Y5M-14DT16H(wasP12Y5M-13DT-8H)duration({days: 1, milliseconds: -1})→P1DT-0.001S(wasPT23H59M59.999S)duration({...}) = duration({...})now returnsfalsefor two durations with equal totals but different(days, seconds)component shapes (was incorrectlytruebecause both sides normalized to the same total-ns value).Why
openCypher CIP
Duration: months, days, seconds+nanoseconds are kept as separate components — months have variable length (28-31 days), and days have variable length under DST. Within a duration, fractional larger units cascade into the next group only (fractional months → days × 30.436875,fractional days → seconds × 86400); whole-unit values do not cascade.Pygraphistry was previously merging everything into
total_nanosecondsand decomposing back via_format_signed_day_time_duration, which lost the days-vs-subday distinction and produced incorrect canonicals for negatives crossing component boundaries.Scope
Closes 3 of 14 wrong-row cases under #1361 / #1353 item #2:
expr-temporal6-6-2—toString({years: 12, months: 5, days: -14, hours: 16})expr-temporal6-6-8—toString({days: 1, milliseconds: -1})expr-temporal7-6-8— equality of two durations with same total seconds but different days+seconds shapeThe remaining 11 are tck-gfql repo issues, filed and deferred:
<gt>placeholder substitution gap inTemporal7.pyexpr-temporal2-6-5): niche historical TZ for Stockholm 1818 LMT — out of scope.Test plan
test_lowering.pypass.test_lowering.py:4541+covering the three Bucket C scenarios.graphistry/tests/compute/gfql/= 1900 passed, 117 skipped, 15 xfailed — no regressions../bin/ruff.sh graphistry/compute/gfql/temporal_text.py graphistry/tests/compute/gfql/cypher/test_lowering.pyclean.dgx-spark— duration canonicalization is pure-python text formatting (no engine-polymorphic dataframe ops); evaluating whether validation is required or can be skipped.Cross-reference
bindingsto refer to them instead #2