Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flink] Disable compaction topology for unaware bucket mode insert when streaming with bounded input stream #2463

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -44,6 +44,7 @@ public class FlinkSinkBuilder {
@Nullable private Map<String, String> overwritePartition;
@Nullable private LogSinkFunction logSinkFunction;
@Nullable private Integer parallelism;
private boolean boundedInput = false;
private boolean compactSink = false;

public FlinkSinkBuilder(FileStoreTable table) {
Expand Down Expand Up @@ -79,6 +80,11 @@ public FlinkSinkBuilder withParallelism(@Nullable Integer parallelism) {
return this;
}

public FlinkSinkBuilder withBoundedInputStream(boolean bounded) {
this.boundedInput = bounded;
return this;
}

public FlinkSinkBuilder forCompact(boolean compactSink) {
this.compactSink = compactSink;
return this;
Expand Down Expand Up @@ -142,7 +148,8 @@ private DataStreamSink<?> buildUnawareBucketSink(DataStream<InternalRow> input)
(AppendOnlyFileStoreTable) table,
overwritePartition,
logSinkFunction,
parallelism)
parallelism,
boundedInput)
.sinkFrom(input);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public SinkRuntimeProvider getSinkRuntimeProvider(Context context) {
.withLogSinkFunction(logSinkFunction)
.withOverwritePartition(overwrite ? staticPartitions : null)
.withParallelism(conf.get(FlinkConnectorOptions.SINK_PARALLELISM))
.withBoundedInputStream(context.isBounded())
.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,19 @@ public class UnawareBucketWriteSink extends FileStoreSink {
private final boolean enableCompaction;
private final AppendOnlyFileStoreTable table;
private final Integer parallelism;
private final boolean boundedInput;

public UnawareBucketWriteSink(
AppendOnlyFileStoreTable table,
Map<String, String> overwritePartitions,
LogSinkFunction logSinkFunction,
Integer parallelism) {
Integer parallelism,
boolean boundedInput) {
super(table, overwritePartitions, logSinkFunction);
this.table = table;
this.enableCompaction = !table.coreOptions().writeOnly();
this.parallelism = parallelism;
this.boundedInput = boundedInput;
}

@Override
Expand All @@ -63,7 +66,8 @@ public DataStreamSink<?> sinkFrom(DataStream<InternalRow> input, String initialC
.get(ExecutionOptions.RUNTIME_MODE)
== RuntimeExecutionMode.STREAMING;
// if enable compaction, we need to add compaction topology to this job
if (enableCompaction && isStreamingMode) {
if (enableCompaction && isStreamingMode && !boundedInput) {
// if streaming mode with bounded input, we disable compaction topology
UnawareBucketCompactionTopoBuilder builder =
new UnawareBucketCompactionTopoBuilder(
input.getExecutionEnvironment(), table.name(), table);
Expand Down
Loading