loserwang1024 commented on code in PR #4053:
URL: https://github.com/apache/flink-cdc/pull/4053#discussion_r2189524583
##########
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:
I move it to FlussHashFunctionProvider
--
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]