Skip to content
Merged
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 @@ -80,6 +80,7 @@
import org.apache.beam.sdk.metrics.Counter;
import org.apache.beam.sdk.metrics.Distribution;
import org.apache.beam.sdk.metrics.Metrics;
import org.apache.beam.sdk.options.StreamingOptions;
import org.apache.beam.sdk.options.ValueProvider;
import org.apache.beam.sdk.options.ValueProvider.StaticValueProvider;
import org.apache.beam.sdk.schemas.Schema;
Expand Down Expand Up @@ -1442,6 +1443,7 @@ public ReadChangeStream withMetadataDatabase(String metadataDatabase) {
return toBuilder().setMetadataDatabase(metadataDatabase).build();
}

/** Specifies the metadata table name. */
public ReadChangeStream withMetadataTable(String metadataTable) {
return toBuilder().setMetadataTable(metadataTable).build();
}
Expand Down Expand Up @@ -1585,6 +1587,11 @@ && getInclusiveStartAt().toSqlTimestamp().after(getInclusiveEndAt().toSqlTimesta
new PostProcessingMetricsDoFn(metrics);

LOG.info("Partition metadata table that will be used is " + partitionMetadataTableName);
input
.getPipeline()
.getOptions()
.as(SpannerChangeStreamOptions.class)
.setMetadataTable(partitionMetadataTableName);

return input
.apply(Impulse.create())
Expand All @@ -1596,6 +1603,19 @@ && getInclusiveStartAt().toSqlTimestamp().after(getInclusiveEndAt().toSqlTimesta
}
}

/**
* Interface to display the name of the metadata table on Dataflow UI. This is only used for
* internal purpose. This should not be used to pass the name of the metadata table.
*/
public interface SpannerChangeStreamOptions extends StreamingOptions {

/** Returns the name of the metadata table. */
String getMetadataTable();

/** Specifies the name of the metadata table. */
void setMetadataTable(String table);
}

private static class ToMutationGroupFn extends DoFn<Mutation, MutationGroup> {
@ProcessElement
public void processElement(ProcessContext c) {
Expand Down