Abacn commented on code in PR #40040:
URL: https://github.com/apache/beam/pull/40040#discussion_r4016418213
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/changestreams/SpannerChangestreamsReadSchemaTransformProvider.java:
##########
@@ -304,42 +299,17 @@ public void finish(FinishBundleContext c) {
}
}
- private static final HashMap<String, SpannerSchema> TABLE_SCHEMAS = new
HashMap<>();
-
private static Schema getTableSchema(SpannerChangestreamsReadConfiguration
config) {
- Pipeline miniPipeline = Pipeline.create();
Review Comment:
Either way, this requires pipeline submission time access to the Spanner
instance. As a follow up, to allow pass a schema so that it won't need IO
resource access at pipeline submission time, or create a Issue to track
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/ReadSpannerSchema.java:
##########
@@ -114,14 +114,46 @@ public void processElement(ProcessContext c) throws
Exception {
String tableName = resultSet.getString(0);
String columnName = resultSet.getString(1);
String ordering = resultSet.getString(2);
-
+ if (!isTableAllowed(allowed, tableName)) {
+ continue;
+ }
builder.addKeyPart(tableName, columnName,
"DESC".equalsIgnoreCase(ordering));
}
}
- c.output(builder.build());
+ return builder.build();
+ }
+
+ private static boolean isTableAllowed(Set<String> allowedTableNames, String
tableName) {
+ if (allowedTableNames.isEmpty()) {
+ return true;
+ }
+ for (String allowed : allowedTableNames) {
Review Comment:
Two things unusual
- allowedTableNames is a Set and we're doing a linear search
- equalsIgnoreCase. Is table name supposed to be case inSensitive?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]