Skip to content

[codegen] Fix equaliser treating null array elements and map values as unequal - #9860

Open
thswlsqls wants to merge 1 commit into
apache:masterfrom
thswlsqls:fix/codegen-null-safe-element-equality
Open

thswlsqls wants to merge 1 commit into
apache:masterfrom
thswlsqls:fix/codegen-null-safe-element-equality

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Purpose

fix #9859

  • ScalarOperatorGens array element and map value checks read only the generateEquals flag (false when either operand is null), so [1, null] and {1 -> null} never equal themselves. Add nullSafeEquals at the three sites, as map keys and EqualiserCodeGenerator fields already do.
  • [codegen] Introduce RecordEqualiser for InternalRow to speed up the judgment of equality #1214 introduced the element and HashMap value checks; [codegen] Fix floating point record equaliser semantics #8534 added the pairwise map path with null-safe key matching but the same flag-only value check.
  • Flink's generateEquals also feeds the SQL = three-valued path (ExprCodeGenerator EQUALS); Paimon's only consumer, RecordEqualiser, is a boolean value-equality contract.
  • With changelog-producer.row-deduplicate=true, an unchanged [1, null]/{1 -> null} upsert emitted a -U/+U pair from LookupChangelogMergeFunctionWrapper; now none.

Tests

  • Added EqualiserCodeGeneratorTest#testArrayEqualiserTreatsNullElementsAsEqual/#testMapEqualiserTreatsNullValuesAsEqual (red pre-fix).
  • mvn -pl paimon-codegen -DfailIfNoTests=false clean install (JDK 11): BUILD SUCCESS, 233 tests, 0 failures.

…s unequal

The array element check and both map value checks in ScalarOperatorGens
only read the result flag of generateEquals, which stays false when either
operand is null. Two null elements or two null map values were therefore
reported as unequal, so ARRAY [1, null] != [1, null] and MAP {1 -> null}
!= {1 -> null} in the generated RecordEqualiser, while top-level fields and
map keys already treat null == null as equal.

Add a nullSafeEquals helper and use it at the three sites so that two nulls
compare equal and a single null compares unequal.

Generated-by: Claude Code
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 RecordEqualiser treats null array elements and null map values as unequal

1 participant