Skip to content
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 @@ -247,4 +247,16 @@ public interface SpannerChangeStreamsToBigQueryOptions
Boolean getDisableDlqRetries();

void setDisableDlqRetries(Boolean value);

@TemplateParameter.Text(
order = 20,
optional = true,
groupName = "Source",
description =
"Semicolon-separated list of Spanner Change Stream TVF names to query and union.",
helpText = "Semicolon-separated list of Spanner Change Stream TVF names to query and union.")
@Default.String("")
String getSpannerChangeStreamTvfNameList();

void setSpannerChangeStreamTvfNameList(String value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,16 @@ public interface SpannerChangeStreamsToGcsOptions
RpcPriority getRpcPriority();

void setRpcPriority(RpcPriority rpcPriority);

@TemplateParameter.Text(
order = 15,
optional = true,
groupName = "Source",
description =
"Semicolon-separated list of Spanner Change Stream TVF names to query and union.",
helpText = "Semicolon-separated list of Spanner Change Stream TVF names to query and union.")
@Default.String("")
String getSpannerChangeStreamTvfNameList();

void setSpannerChangeStreamTvfNameList(String value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,16 @@ public interface SpannerChangeStreamsToPubSubOptions extends DataflowPipelineOpt
Boolean getUseSpannerEmulatorHost();

void setUseSpannerEmulatorHost(Boolean value);

@TemplateParameter.Text(
order = 20,
optional = true,
groupName = "Source",
description =
"Semicolon-separated list of Spanner Change Stream TVF names to query and union.",
helpText = "Semicolon-separated list of Spanner Change Stream TVF names to query and union.")
@Default.String("")
String getSpannerChangeStreamTvfNameList();

void setSpannerChangeStreamTvfNameList(String value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import com.google.cloud.teleport.v2.transforms.FileFormatFactorySpannerChangeStreams;
import com.google.cloud.teleport.v2.utils.DurationUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.PipelineResult;
import org.apache.beam.sdk.io.gcp.spanner.SpannerConfig;
Expand Down Expand Up @@ -137,6 +139,15 @@ public static PipelineResult run(SpannerChangeStreamsToGcsOptions options) {
? null
: options.getSpannerMetadataTableName();

String tvfNameListString = options.getSpannerChangeStreamTvfNameList();
List<String> tvfNameList = null;
if (tvfNameListString != null && !tvfNameListString.isEmpty()) {
tvfNameList =
Arrays.stream(tvfNameListString.split(";"))
.filter(name -> !name.trim().isEmpty())
.collect(Collectors.toList());
}

final RpcPriority rpcPriority = options.getRpcPriority();
SpannerConfig spannerConfig =
SpannerConfig.create()
Expand All @@ -162,7 +173,8 @@ public static PipelineResult run(SpannerChangeStreamsToGcsOptions options) {
.withInclusiveStartAt(startTimestamp)
.withInclusiveEndAt(endTimestamp)
.withRpcPriority(rpcPriority)
.withMetadataTable(metadataTableName))
.withMetadataTable(metadataTableName)
.withTvfNameList(tvfNameList))
.apply(
"Creating " + options.getWindowDuration() + " Window",
Window.into(FixedWindows.of(DurationUtils.parseDuration(options.getWindowDuration()))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import com.google.cloud.teleport.v2.transforms.FileFormatFactorySpannerChangeStreamsToPubSub;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.PipelineResult;
import org.apache.beam.sdk.io.gcp.spanner.SpannerConfig;
Expand Down Expand Up @@ -155,6 +157,15 @@ public static PipelineResult run(SpannerChangeStreamsToPubSubOptions options) {
? null
: options.getSpannerMetadataTableName();

String tvfNameListString = options.getSpannerChangeStreamTvfNameList();
List<String> tvfNameList = null;
if (tvfNameListString != null && !tvfNameListString.isEmpty()) {
tvfNameList =
Arrays.stream(tvfNameListString.split(";"))
.filter(name -> !name.trim().isEmpty())
.collect(Collectors.toList());
}

final RpcPriority rpcPriority = options.getRpcPriority();
SpannerConfig spannerConfig =
SpannerConfig.create()
Expand Down Expand Up @@ -187,7 +198,8 @@ public static PipelineResult run(SpannerChangeStreamsToPubSubOptions options) {
.withInclusiveStartAt(startTimestamp)
.withInclusiveEndAt(endTimestamp)
.withRpcPriority(rpcPriority)
.withMetadataTable(metadataTableName))
.withMetadataTable(metadataTableName)
.withTvfNameList(tvfNameList))
.apply(
"Convert each record to a PubsubMessage",
FileFormatFactorySpannerChangeStreamsToPubSub.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -324,6 +325,17 @@ public static PipelineResult run(SpannerChangeStreamsToBigQueryOptions options)
readChangeStream = readChangeStream.withMetadataTable(spannerMetadataTableName);
}

String tvfNameListString = options.getSpannerChangeStreamTvfNameList();
if (tvfNameListString != null && !tvfNameListString.isEmpty()) {
List<String> tvfNameList =
Arrays.stream(tvfNameListString.split(";"))
.filter(name -> !name.trim().isEmpty())
.collect(Collectors.toList());
if (!tvfNameList.isEmpty()) {
readChangeStream = readChangeStream.withTvfNameList(tvfNameList);
}
}

PCollection<DataChangeRecord> dataChangeRecord =
pipeline
.apply("Read from Spanner Change Streams", readChangeStream)
Expand Down
Loading