TheNeuralBit commented on a change in pull request #12090:
URL: https://github.com/apache/beam/pull/12090#discussion_r447075292



##########
File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/pubsub/PubsubIOJsonTable.java
##########
@@ -139,65 +134,19 @@ static PubsubIOJsonTable 
withConfiguration(PubsubIOTableConfiguration config) {
 
   @Override
   public Schema getSchema() {
-    return config.getSchema();
+    return schema;
   }
 
   @Override
   public PCollection<Row> buildIOReader(PBegin begin) {
-    PCollectionTuple rowsWithDlq =
-        begin
-            .apply("ReadFromPubsub", readMessagesWithAttributes())
-            .apply(
-                "PubsubMessageToRow",
-                PubsubMessageToRow.builder()
-                    .messageSchema(getSchema())
-                    .useDlq(config.useDlq())
-                    .useFlatSchema(config.getUseFlatSchema())
-                    .build());
-    rowsWithDlq.get(MAIN_TAG).setRowSchema(getSchema());
-
-    if (config.useDlq()) {
-      rowsWithDlq.get(DLQ_TAG).apply(writeMessagesToDlq());
-    }
-
-    return rowsWithDlq.get(MAIN_TAG);
-  }
-
-  private PubsubIO.Read<PubsubMessage> readMessagesWithAttributes() {
-    PubsubIO.Read<PubsubMessage> read =
-        PubsubIO.readMessagesWithAttributes().fromTopic(config.getTopic());
-
-    return config.useTimestampAttribute()
-        ? read.withTimestampAttribute(config.getTimestampAttribute())
-        : read;
-  }
-
-  private PubsubIO.Write<PubsubMessage> writeMessagesToDlq() {
-    PubsubIO.Write<PubsubMessage> write = 
PubsubIO.writeMessages().to(config.getDeadLetterQueue());
-
-    return config.useTimestampAttribute()
-        ? write.withTimestampAttribute(config.getTimestampAttribute())
-        : write;
+    PTransform<PBegin, PCollection<Row>> readerTransform = 
pubsubSchemaIO.buildReader();
+    return readerTransform.expand(begin);

Review comment:
       Good catch, thanks Robin. Same thing in `buildIOWriter`




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to