Skip to content

test(isthmus): use loose round-trip comparison for statistical aggregate tests#1023

Merged
vbarua merged 1 commit into
substrait-io:mainfrom
nielspardon:fix/statistical-aggregate-roundtrip-comparison
Jul 22, 2026
Merged

test(isthmus): use loose round-trip comparison for statistical aggregate tests#1023
vbarua merged 1 commit into
substrait-io:mainfrom
nielspardon:fix/statistical-aggregate-roundtrip-comparison

Conversation

@nielspardon

Copy link
Copy Markdown
Member

Problem

The round-trip helper that StatisticalFunctionTest's integer-input cases relied on (assertFullRoundTripWithIdentityProjectionWorkaround) was removed in #1009, but those cases were added in #780. Because #1009 branched before #780 merged, it did not see the new call sites, leaving the :isthmus test module uncompilable on main.

Why not just use assertFullRoundTrip

These cases can't use the standard assertFullRoundTrip. The statistical-aggregate cast rewrite (castStatisticalAggregatesToFloatingPoint) stacks a cast(... AS fp64) projection over the aggregate's input projection. When the plan is rebuilt on the Substrait → Calcite leg, Calcite merges those projections and prunes the redundant pass-through column — project-merge/column-pruning, distinct from the redundant identity projections #1009 now elides. So the plan produced straight from SQL differs structurally from the one produced after a Calcite → Substrait → Calcite round trip, and a strict equality assertion fails.

Fix

Switch the three integer-input cases to the existing assertSqlSubstraitRelRoundTripLoosePojoComparison helper, which is documented for exactly this optimizer-normalization situation: it asserts that the normalized plan is stable across a round trip rather than requiring equality with the initial plan. No new helper is reintroduced.

The fp32/fp64 cases keep the stronger assertFullRoundTrip, and usesEnumArgSignature still pins the Substrait function structure.

Verification

  • ./gradlew :isthmus:test --tests "io.substrait.isthmus.StatisticalFunctionTest" → 14/14 pass
  • ./gradlew :isthmus:spotlessCheck :isthmus:pmdTest → clean

🤖 Generated with AI

…te integer inputs

The round-trip helper that StatisticalFunctionTest's integer-input cases
relied on was removed, leaving the isthmus test module uncompilable on main.

Those cases cannot use the standard assertFullRoundTrip: the statistical-
aggregate cast rewrite stacks a cast projection over the aggregate's input
projection, which Calcite merges (and prunes the redundant column) when it
rebuilds the plan on the Substrait -> Calcite leg. The plan straight from SQL
therefore differs from the one after a Calcite -> Substrait -> Calcite round
trip.

Switch them to the existing assertSqlSubstraitRelRoundTripLoosePojoComparison
helper, which is documented for exactly this optimizer-normalization case: it
asserts that the normalized plan is stable across a round trip rather than
requiring equality with the initial plan.
@nielspardon
nielspardon requested a review from vbarua July 22, 2026 18:09
@vbarua vbarua changed the title fix(isthmus): use loose round-trip comparison for statistical aggregate integer inputs test(isthmus): use loose round-trip comparison for statistical aggregate tests Jul 22, 2026
@vbarua
vbarua merged commit 13fba9f into substrait-io:main Jul 22, 2026
15 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.

2 participants