tzulitai commented on a change in pull request #6440: [FLINK-9979] [table] Support a FlinkKafkaPartitioner for Kafka table sink factory URL: https://github.com/apache/flink/pull/6440#discussion_r206879886
########## File path: flink-connectors/flink-connector-kafka-base/src/main/java/org/apache/flink/table/descriptors/Kafka.java ########## @@ -175,6 +183,69 @@ public Kafka startFromSpecificOffset(int partition, long specificOffset) { return this; } + /** + * Configures how to partition records from Flink's partitions into Kafka's partitions. + * + * <p>This strategy ensures that each Flink partition ends up in one Kafka partition. + * + * <p>Note: One Kafka partition can contain multiple Flink partitions. Examples: + * + * <p>More Flink partitions than Kafka partitions. Some (or all) Kafka partitions contain + * the output of more than one flink partition: + * <pre> + * Flink Sinks Kafka Partitions + * 1 ----------------> 1 + * 2 --------------/ + * 3 -------------/ + * 4 ------------/ + * </pre> + * + * + * <p>Fewer Flink partitions than Kafka partitions: + * <pre> + * Flink Sinks Kafka Partitions + * 1 ----------------> 1 + * 2 ----------------> 2 + * 3 + * 4 + * 5 + * </pre> + * + * @see org.apache.flink.streaming.connectors.kafka.partitioner.FlinkFixedPartitioner + */ + public Kafka sinkPartitionerFixed() { + sinkPartitioner = CONNECTOR_SINK_PARTITIONER_VALUE_FIXED; + sinkPartitionerClass = null; + return this; + } + + /** + * Configures how to partition records from Flink's partitions into Kafka's partitions. + * + * <p>This strategy ensures that records will be distributed to Kafka partitions in a + * round-robin fashion. + * + * <p>Note: This strategy is useful to avoid an unbalanced partitioning. However, it will + * cause a lot of network connections between all the Flink instances and all the Kafka brokers. + */ + public Kafka sinkPartitionerRoundRobin() { + sinkPartitioner = CONNECTOR_SINK_PARTITIONER_VALUE_ROUND_ROBIN; + sinkPartitionerClass = null; + return this; + } + + /** + * Configures how to partition records from Flink's partitions into Kafka's partitions. + * + * <p>This strategy allows for a custom partitioner by providing an implementation + * of {@link FlinkKafkaPartitioner}. + */ + public Kafka sinkPartitionerCustom(Class<? extends FlinkKafkaPartitioner> partitionerClass) { Review comment: Alright, that makes sense. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services