test(integ-test): stabilize floating window SUM cases - #5744
Conversation
PR Reviewer Guide 🔍(Review updated until commit e13e060)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to e13e060
Previous suggestionsSuggestions up to commit 83fae4d
|
dai-chen
left a comment
There was a problem hiding this comment.
I forgot where is exact the code. But could you double check if adjust precision is the better way like here https://github.com/opensearch-project/sql/blob/main/integ-test/src/test/java/org/opensearch/sql/correctness/runner/resultset/Row.java#L37
The SQL correctness runner compares OpenSearch with H2 and SQLite after rounding floating cells to two decimals with CEILING. The legacy SQL engine keeps SUM(FLOAT) in single precision, so multi-shard merge order can move the result across a cent boundary even though the window is correct. Cast the summed operand to DOUBLE in the two affected window queries. This keeps the tests focused on window behavior without requiring an exact cent from an order-dependent float32 accumulator. The ordered case also had no outer ORDER BY. Its internal window ordering contains 17 FlightDelayMin=0 peers, so the harness compared a shard-dependent physical row order positionally. Add a unique outer ordering using FlightNum without changing the internal RANGE window frame. Signed-off-by: Eric Wei <menwe@amazon.com>
83fae4d to
e13e060
Compare
|
Persistent review updated to latest commit e13e060 |
Description
Two SQL correctness cases were unstable when the flights fixture used multiple shards:
SUM(DistanceMiles) OVER ()intermittently differed from H2 and SQLite by0.01.SUM(DistanceMiles) OVER (ORDER BY FlightDelayMin)also compared rows positionally even though 17 rows share the same ordering key and the query had no outerORDER BY.The correctness runner rounds floating cells to two decimals with
CEILINGand then compares them exactly. The legacy SQL engine preservesSUM(FLOAT)asFLOAT, so shard-dependent input order can move the single-precision result across a cent boundary without changing the window semantics.This change casts only the summed operand in these two queries to
DOUBLE. It also adds a unique outer ordering to the ordered case. The internal window order and its defaultRANGEframe remain unchanged.No production code, shared comparator, or fixture is modified.
Validation
Focused tests used the official SQL correctness comparison framework against OpenSearch, H2, and SQLite.
Mutation checks:
DOUBLEcasts reproduced floating SUM failures in 10/10 five-shard runs.compileTestJavaandgit diff --checkpass.Related Issues
None. This is a test-only alignment with the existing approximate floating-point contract.
Check List
--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.