Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public Set<ConfigOption<?>> optionalOptions() {
options.add(IcebergDataSinkOptions.PARTITION_KEY);
options.add(IcebergDataSinkOptions.SINK_COMPACTION_ENABLED);
options.add(IcebergDataSinkOptions.SINK_COMPACTION_COMMIT_INTERVAL);
options.add(IcebergDataSinkOptions.SINK_COMPACTION_PARALLELISM);
return options;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public SimpleVersionedSerializer<WriteResultWrapper> getWriteResultSerializer()
return new WriteResultWrapperSerializer();
}

public int partitionCustom(int bucket, int numPartitions) {
return Math.floorMod(bucket, numPartitions);
}

@Override
public void addPostCommitTopology(
DataStream<CommittableMessage<WriteResultWrapper>> committableMessageDataStream) {
Expand All @@ -136,7 +140,7 @@ public void addPostCommitTopology(
// Shuffle by different table id.
DataStream<CommittableMessage<WriteResultWrapper>> keyedStream =
committableMessageDataStream.partitionCustom(
(bucket, numPartitions) -> bucket % numPartitions,
this::partitionCustom,
(committableMessage) -> {
if (committableMessage instanceof CommittableWithLineage) {
WriteResultWrapper multiTableCommittable =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,12 @@ private List<String> fetchTableContent(Catalog catalog, TableId tableId) {
}
return results;
}

@Test
public void testPartitionCustom() {
IcebergSink icebergSink =
new IcebergSink(new HashMap<>(), null, null, CompactionOptions.builder().build());
Assertions.assertThat(icebergSink.partitionCustom(-5, 4)).isEqualTo(3);
Assertions.assertThat(icebergSink.partitionCustom(5, 4)).isEqualTo(1);
}
}
Loading