Repository navigation
fix(join): canonicalize DOUBLE signed zero across spill modes - #26450
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
7c933ae to
d234f5a
Compare
aptend
left a comment
There was a problem hiding this comment.
Reviewed the signed-zero canonicalization across resident, initial-spill, and re-spill paths. Focused contract tests passed with -race -count=100, and all six owning packages passed with -race -count=1.
VioletQwQ-0
left a comment
There was a problem hiding this comment.
Reviewed the current exact head d234f5a from multiple angles. I did not find a production-correctness blocker in the DOUBLE signed-zero canonicalization across resident, initial-spill, and re-spill paths.
The only remaining validation blocker is the required Matrixone Utils CI / Coverage check: PR coverage is 61.48%, below the 75% threshold. Please add focused coverage for the new FLOAT64 specialized branches, especially const, const-null, nullable/mixed-NULL, non-zero start, and const/short-vector hashing with a non-zero seed, then re-request review after the check is green.
d234f5a to
73a335a
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head 73a335ae27d590f0b7a0820f2877273593cf4a03: no blocking findings.
Signed-zero canonicalization is defined once in the typed key codec and is consistently consumed by resident IntHashMap/composite StrHashMap, initial spill partitioning, and recursive re-spill. It preserves NULL behavior, non-zero starts, const vectors, original payload values, and spill-file format. The intentionally incomplete equality cases remain explicitly skipped and tracked by #26432 rather than being blessed as expected behavior.
Fresh local evidence: hashmap, HashJoin, DedupJoin, and RightDedupJoin signed-zero contracts all pass under -race -count=3 across resident/initial-spill/re-spill modes, including cleanup counters; go build and go vet pass for all six affected packages. Final diff is clean, latest CI is green, and the PR remains MERGEABLE.
What type of PR is this?
Which issue(s) this PR fixes:
Related to #26432. This is an incremental contract fix; it intentionally does not close the whole issue.
What this PR does / why we need it
Spill is not a separate equality domain. A join key that is equal under SQL must remain equivalent in every physical phase: resident hashmap lookup, initial spill partitioning, probe partitioning, and recursive re-spill.
This PR fixes one concrete violation of that invariant: SQL
DOUBLE +0 = -0was true in the scalar evaluator, while raw IEEE-754 bytes sent the two values to different hashmap keys or spill partitions.The implementation defines signed-zero canonicalization once in
keycodecand uses the same typed contract in all CN-local phases:IntHashMapkeys;StrHashMapkeys;Resident hashmaps dispatch once per vector and retain specialized row loops. Initial spill and re-spill call the same vector-level partition-hash implementation. Common non-
DOUBLEloops are unchanged; there is no per-row interface dispatch or allocation.Only the ephemeral hashmap/partition key is canonicalized. Input vectors, result values, and serialized spill batches retain their original values and format, so this introduces no spill-file or wire-format change.
Contract status
Each pending case first executes the real scalar
=evaluator as the SQL oracle, then skips before asserting the known-incomplete physical behavior. The PR does not bless a current mismatch as expected output.=DOUBLE +0 / -0TRUEFLOAT32(scale=2) 1.234 / 1.23TRUEJSON 1 / 1.0TRUEVECF32 +0 / -0TRUEDOUBLE NaN / NaNFALSEDOUBLE NULL / NULLNULLFLOAT64is not currently eligible for the planner's remote-shuffle key path. This PR establishes the local resident/spill/re-spill invariant; remote typed-key equivalence and the remaining types stay tracked by #26432.Regression design
These are deterministic operator-level tests, not large-data BVTs or embedded-cluster SQL. A low spill threshold selects the physical mode with 257 build rows plus one probe row, so runtime and memory remain small while the same batches traverse real join operators and spill files.
-0probe must return exactly the 129 distinct payloads belonging to the skewed+0/-0build equivalence class—no loss, duplicate, wrong build row, or NULL payload.42, with exact capture NULL states.ErrDuplicateEntryforcontract_key, with zero output before and at the error.The fixtures also prove that:
start > 0);A public hashmap-iterator contract matrix covers both
IntHashMapand compositeStrHashMap: flat vectors with a non-zero start, nullable vectors with and without actual NULLs, NULL filtering, NULL-as-key, constants, and constant NULLs. It assertszValues, live group IDs, andGroupCountacross insert and find operations.Scope and performance
Microbenchmark setup: latest
mainversus this branch, identical harness,GOMAXPROCS=1, five samples/median, 8192 spill rows and 256 resident hashmap rows.mainns/rowINT64DOUBLEINT64DOUBLEINT64DOUBLEThe common integer paths show no material regression. The
DOUBLEspecializations are faster than the previous raw-byte path while implementing SQL-equivalent hashing.Test plan
All commands use the repository's deterministic CGo/libmo wrapper and were rerun after rebasing onto
origin/mainat38ce3a774a.Focused race stress, all pass with
-race -count=100:TestHashJoinKeyEqualityContractTestDedupJoinDoubleSignedZeroContractTestRightDedupJoinDoubleSignedZeroContractTestHashMapsFloat64SignedZeroContractComplete non-race and
-race -count=1suites both pass for all owning packages:pkg/common/hashmappkg/sql/colexec/hashbuildpkg/sql/colexec/spillutilpkg/sql/colexec/hashjoinpkg/sql/colexec/dedupjoinpkg/sql/colexec/rightdedupjoingo vetandgo build -mod=readonlypass for the same six packages. The new hashmap state matrix directly exercises theFLOAT64const, nullable, NULL, non-zero-start, and composite-key branches that the prior CI coverage review identified.