leonardBang commented on code in PR #4053:
URL: https://github.com/apache/flink-cdc/pull/4053#discussion_r2189417343
##########
flink-cdc-common/src/main/java/org/apache/flink/cdc/common/sink/DefaultDataChangeEventHashFunctionProvider.java:
##########
@@ -63,10 +64,15 @@ public int hashcode(DataChangeEvent event) {
objectsToHash.add(tableId.getTableName());
// Primary key
- RecordData data =
- event.op().equals(OperationType.DELETE) ? event.before() :
event.after();
- for (FieldGetter primaryKeyGetter : primaryKeyGetters) {
- objectsToHash.add(primaryKeyGetter.getFieldOrNull(data));
+ if (!primaryKeyGetters.isEmpty()) {
+ RecordData data =
+ event.op().equals(OperationType.DELETE) ?
event.before() : event.after();
+ for (FieldGetter primaryKeyGetter : primaryKeyGetters) {
+ objectsToHash.add(primaryKeyGetter.getFieldOrNull(data));
+ }
+ } else {
+ // Avoid sending all events to the same subtask when table has
no primary key.
+ objectsToHash.add(ThreadLocalRandom.current().nextInt());
Review Comment:
We should not change the COMMON logic in a specific connector
implementation, this will lead to data correct issue in the case that changelog
comes from mysql table witout primary key
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]