Skip to content

[codegen] Fix generated map comparator comparing values by key type - #8763

Merged
JingsongLi merged 1 commit into
apache:masterfrom
thswlsqls:fix/codegen-map-value-comparison-type
Jul 21, 2026
Merged

[codegen] Fix generated map comparator comparing values by key type#8763
JingsongLi merged 1 commit into
apache:masterfrom
thswlsqls:fix/codegen-map-value-comparison-type

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Purpose

fix #8762

  • GenerateUtils.generateMapCompare built the value array type from mapType.getKeyType instead of getValueType, so the generated comparator read MAP value elements with the key type.
  • For maps whose key and value types differ (e.g. MAP<INT, STRING>) this gave a wrong comparison result or a runtime ClassCastException.
  • Sibling generateMultisetCompare and ScalarOperatorGens.generateMapComparison already pass key and value types separately.

Tests

  • Added CodeGenUtilsTest#testMapComparatorComparesValuesWithValueType comparing MAP<INT, STRING> rows with equal keys and differing values; it fails (ClassCastException) before the fix and passes after.
  • mvn -pl paimon-core -Dtest=CodeGenUtilsTest test — 15 tests passed (JDK 11). mvn -pl paimon-codegen,paimon-core spotless:check passed.

GenerateUtils.generateMapCompare built the value array type from
mapType.getKeyType instead of getValueType, so the generated comparator
read MAP value elements with the key type. For maps whose key and value
types differ (e.g. MAP<INT, STRING>) this produced wrong comparison
results or a runtime ClassCastException. The sibling generateMultisetCompare
and ScalarOperatorGens both pass key and value types separately.

Generated-by: Claude Code
@JingsongLi

Copy link
Copy Markdown
Contributor

+1

@JingsongLi
JingsongLi merged commit ce76ab9 into apache:master Jul 21, 2026
11 of 12 checks passed
@thswlsqls
thswlsqls deleted the fix/codegen-map-value-comparison-type branch July 21, 2026 10:15
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.

[Bug] Generated map comparator compares values using the key type

2 participants