Skip to content

Flink: Fix RANGE distribution ignoring user-specified equality fields#17276

Draft
thswlsqls wants to merge 1 commit into
apache:mainfrom
thswlsqls:fix/flink-hashkeygenerator-range-equality-fields
Draft

Flink: Fix RANGE distribution ignoring user-specified equality fields#17276
thswlsqls wants to merge 1 commit into
apache:mainfrom
thswlsqls:fix/flink-hashkeygenerator-range-equality-fields

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Closes #17274

Summary

  • case RANGE in HashKeyGenerator.getKeySelector() tested schema.identifierFieldIds().isEmpty() but passed the equalityFields parameter to equalityFieldKeySelector. Siblings case NONE and case HASH test equalityFields.isEmpty(); RANGE now matches.
  • Previously, equality fields on a schema without identifier fields fell back to round-robin while DynamicWriter still emitted equality deletes for them; the "because there are no equality fields set" warning, left unchanged, now matches the condition.
  • Backward compatible: equalityFields comes from DynamicSinkUtil.resolveEqualityFieldNames(record.equalityFields(), schema), which falls back to schema.identifierFieldNames() when unset, so equalityFields.isEmpty() implies schema.identifierFieldIds().isEmpty(). getKeySelector is private with one caller, so only the user-specified case changes behavior.
  • Flink: Honor schema identifier fields in dynamic-sink record routing #16243 lifted that fallback into the caller, making the RANGE schema check redundant.

Testing done

  • Added TestHashKeyGenerator#rangeModeWithEqualityFields (RANGE, equality fields {"id"}, schema without identifier fields). Fails before the change, passes after.
  • :iceberg-flink:iceberg-flink-2.1:test --tests "*TestHashKeyGenerator*" — 17 tests passed.
  • Same task for *TestDynamicRecordProcessor*, *TestDynamicWriter*, *TestDynamicRecordWithConfig*, *TestTableUpdater* — 30 tests passed.
  • spotlessCheck, checkstyleMain, checkstyleTest passed. The full module :check was not run — its MiniCluster suites do not complete here. Flink is not a REVAPI module.

The RANGE branch of HashKeyGenerator.getKeySelector() checked
schema.identifierFieldIds() but passed the equalityFields parameter to
equalityFieldKeySelector. Its NONE and HASH siblings both check
equalityFields, so RANGE now does the same.
equalityFields is resolved by DynamicSinkUtil.resolveEqualityFieldNames,
which falls back to the schema identifier field names when the user sets
none. The two checks therefore only disagreed when a user set equality
fields on a schema without identifier fields: RANGE fell back to
round-robin routing while DynamicWriter still wrote equality deletes for
those fields.

Generated-by: Claude Code
@github-actions github-actions Bot added the flink label Jul 17, 2026
@thswlsqls
thswlsqls marked this pull request as draft July 17, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flink: RANGE distribution mode ignores user-specified equality fields in dynamic sink

1 participant