Skip to content
Open
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
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
<jacoco.version>0.8.13</jacoco.version>

<!-- Beam and linked versions -->
<beam.version>2.73.0</beam.version>
<beam-python.version>2.73.0</beam-python.version>
<beam.version>2.74.0</beam.version>
<beam-python.version>2.74.0</beam-python.version>
<beam-maven-repo></beam-maven-repo>

<!-- Common dependency versions -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,15 @@ public interface SpannerChangeStreamsToBigQueryOptions
Boolean getDisableDlqRetries();

void setDisableDlqRetries(Boolean value);

@TemplateParameter.Text(
order = 20,
optional = true,
groupName = "Source",
description = "Colon separated list of change streams TVF names to query and union",
helpText = "Colon separated list of change streams TVF names to query and union. Note that using colon instead of comma because gcloud does not allow comma in the parameter value.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to use gcloud here? In connector codebase, we should not use gcloud.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template is typically launched with gcloud command with commannd line arguments.
This is template, not the connector.

@Default.String("")
String getSpannerChangeStreamTvfNameList();

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

void setRpcPriority(RpcPriority rpcPriority);

@TemplateParameter.Text(
order = 15,
optional = true,
groupName = "Source",
description = "Colon separated list of change streams TVF names to query and union",
helpText = "Colon separated list of change streams TVF names to query and union. Note that using colon instead of comma because gcloud does not allow comma in the parameter value.")
@Default.String("")
String getSpannerChangeStreamTvfNameList();

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

void setUseSpannerEmulatorHost(Boolean value);

@TemplateParameter.Text(
order = 20,
optional = true,
groupName = "Source",
description = "Colon separated list of change streams TVF names to query and union",
helpText = "Colon separated list of change streams TVF names to query and union. Note that using colon instead of comma because gcloud does not allow comma in the parameter value.")
@Default.String("")
String getSpannerChangeStreamTvfNameList();

void setSpannerChangeStreamTvfNameList(String value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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 org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.PipelineResult;
Expand Down Expand Up @@ -137,6 +138,12 @@ public static PipelineResult run(SpannerChangeStreamsToGcsOptions options) {
? null
: options.getSpannerMetadataTableName();

String tvfNameListString = options.getSpannerChangeStreamTvfNameList();
List<String> tvfNameList = null;
if (tvfNameListString != null && !tvfNameListString.isEmpty()) {
tvfNameList = Arrays.asList(tvfNameListString.split(":"));
}

final RpcPriority rpcPriority = options.getRpcPriority();
SpannerConfig spannerConfig =
SpannerConfig.create()
Expand All @@ -162,7 +169,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,6 +24,7 @@
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 org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.PipelineResult;
Expand Down Expand Up @@ -155,6 +156,12 @@ public static PipelineResult run(SpannerChangeStreamsToPubSubOptions options) {
? null
: options.getSpannerMetadataTableName();

String tvfNameListString = options.getSpannerChangeStreamTvfNameList();
List<String> tvfNameList = null;
if (tvfNameListString != null && !tvfNameListString.isEmpty()) {
tvfNameList = Arrays.asList(tvfNameListString.split(":"));
}

final RpcPriority rpcPriority = options.getRpcPriority();
SpannerConfig spannerConfig =
SpannerConfig.create()
Expand Down Expand Up @@ -187,7 +194,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,14 @@ public static PipelineResult run(SpannerChangeStreamsToBigQueryOptions options)
readChangeStream = readChangeStream.withMetadataTable(spannerMetadataTableName);
}

String tvfNameListString = options.getSpannerChangeStreamTvfNameList();
if (tvfNameListString != null && !tvfNameListString.isEmpty()) {
List<String> tvfNameList = Arrays.asList(tvfNameListString.split(":"));
if (!tvfNameList.isEmpty()) {
readChangeStream = readChangeStream.withTvfNameList(tvfNameList);
}
}

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