Conversation
…_map aggregators apache#9249 made collect and merge_map compare binary elements and keys by value, but it recognised byte[]-backed types by the BINARY_STRING family only. GEOMETRY and GEOGRAPHY (apache#9251, merged the same day) are byte[] as well and still fell through to identity equality, so a distinct collect kept the same WKB value twice and merge_map kept one entry per occurrence of the same key. FieldCollectAgg also built its equaliser only for distinct arrays, so retract() on a non-distinct binary array compared byte[] by identity and never removed anything. - BinaryMapKeys.isBinary: match BINARY, VARBINARY, GEOMETRY, GEOGRAPHY (the roots InternalArray.createElementGetter reads with getBinary) - FieldCollectAgg.needsEqualiser: reuse BinaryMapKeys.isBinary - FieldCollectAgg: build the equaliser from the element type alone and gate de-duplication in agg() on distinct Generated-by: Claude Code
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.
Purpose
fix #9869
needsEqualiser()andBinaryMapKeys.isBinary()only matchedBINARY_STRING, so GEOMETRY/GEOGRAPHY (alsobyte[]) were compared by identity: distinctcollect/merge_mapkept duplicates.FieldCollectAggbuilt its equaliser only for distinct arrays, so a non-distinct binaryretract()removed nothing.isBinary()matches BINARY, VARBINARY, GEOMETRY, GEOGRAPHY (thegetBinaryroots ofcreateElementGetter) andneedsEqualiser()reuses it; the equaliser depends on the element type alone,agg()gates de-duplication ondistinct.Float.compare), like distinct.Tests
FieldAggregatorTest#testFieldCollectAggWithDistinctGeospatial,#testFieldMergeMapAggWithGeospatialKey,#testFieldMergeMapWithKeyTimeAggWithGeospatialKey,#testFieldCollectAggRetractWithBinary(fail without the fix),#testFieldCollectAggKeepsDuplicatesWithBinary(regression guard).FieldAggregatorTest: 106 tests, 0 failures.mvn -pl paimon-core clean install(checkstyle, spotless, enforcer, surefire) — 5441 tests, 0 failures; onlyPostgresqlCatalogTest(needs Docker) could not start locally.