gong commented on code in PR #8209:
URL: https://github.com/apache/inlong/pull/8209#discussion_r1250124633
##########
inlong-sort/sort-flink/sort-flink-v1.13/sort-connectors/kafka/src/main/java/org/apache/inlong/sort/kafka/table/KafkaDynamicTableFactory.java:
##########
@@ -260,15 +268,23 @@ private Optional<FlinkKafkaPartitioner<RowData>>
getFlinkKafkaPartitioner(
inLongFixedPartitionPartitioner.setSinkMultipleFormat(tableOptions.getOptional(SINK_MULTIPLE_FORMAT)
.orElse(null));
return Optional.of(inLongFixedPartitionPartitioner);
- }
- if (tableOptions.getOptional(SINK_PARTITIONER).isPresent()
+ } else if (tableOptions.getOptional(SINK_PARTITIONER).isPresent()
&&
SINK_PARTITIONER_VALUE_RAW_HASH.equals(tableOptions.getOptional(SINK_PARTITIONER).get()))
{
RawDataHashPartitioner<RowData> rawHashPartitioner = new
RawDataHashPartitioner<>(tableOptions
.getOptional(DATASOURCE_PARTITION_MAP).orElse(Collections.emptyMap()));
rawHashPartitioner.setSinkMultipleFormat(tableOptions.getOptional(SINK_MULTIPLE_FORMAT).orElse(null));
rawHashPartitioner.setPartitionPattern(tableOptions.getOptional(SINK_MULTIPLE_PARTITION_PATTERN)
.orElse(null));
return Optional.of(rawHashPartitioner);
+ } else if (tableOptions.getOptional(SINK_PARTITIONER).isPresent()
+ &&
SINK_PARTITIONER_VALUE_PRIMARY_KEY.equals(tableOptions.getOptional(SINK_PARTITIONER).get()))
{
+ SingleTablePrimaryKeyPartitioner<RowData> primaryKeyPartitioner =
new SingleTablePrimaryKeyPartitioner<>();
+ // the pattern is different from the ${} pattern, it is a
truncated string of schema fields.
+
primaryKeyPartitioner.setPartitionNumber(tableOptions.getOptional(SINK_FIXED_IDENTIFIER).orElse(null));
+
primaryKeyPartitioner.setPartitionKey(tableOptions.getOptional(SINK_MULTIPLE_PARTITION_PATTERN)
Review Comment:
you reuse SINK_MULTIPLE_PARTITION_PATTERN to parse partition, pattern define
of SINK_MULTIPLE_PARTITION_PATTERN is different with your define. I suggest add
description in `withDescription`.
```java
public static final ConfigOption<String> SINK_MULTIPLE_PARTITION_PATTERN =
ConfigOptions.key("sink.multiple.partition-pattern")
.stringType()
.noDefaultValue()
.withDescription("option
'sink.multiple.partition-pattern' used when the partitioner is raw-hash.");
```
And update inlong document.
--
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]