benWize commented on a change in pull request #15174:
URL: https://github.com/apache/beam/pull/15174#discussion_r698874702



##########
File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamAggregationRel.java
##########
@@ -243,9 +247,70 @@ private Transform(
       if (windowFn != null) {
         windowedStream = assignTimestampsAndWindow(upstream);
       }
-
       validateWindowIsSupported(windowedStream);
+      return createCombiner(pinput, windowedStream);
+    }
+
+    private PCollection<Row> createCombiner(
+        PCollectionList<Row> pinput, PCollection<Row> windowedStream) {
+      // Check if have fields to be grouped
+      if (groupSetCount > 0) {
+        PTransform<PCollection<Row>, PCollection<Row>> combiner = 
createGroupCombiner();
+        boolean verifyRowValues =
+            
pinput.getPipeline().getOptions().as(BeamSqlPipelineOptions.class).getVerifyRowValues();
+        return windowedStream
+            .apply(combiner)
+            .apply(
+                "mergeRecord",
+                ParDo.of(
+                    mergeRecord(outputSchema, windowFieldIndex, ignoreValues, 
verifyRowValues)))
+            .setRowSchema(outputSchema);
+      }
+      PTransform<PCollection<Row>, PCollection<Row>> combiner = 
createGlobalCombiner();
+      return windowedStream.apply(combiner).setRowSchema(outputSchema);
+    }
 
+    private PTransform<PCollection<Row>, PCollection<Row>> 
createGlobalCombiner() {

Review comment:
       I created a new interface in order to make the code reusable for both 
`global` and `byFields` combiners.




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


Reply via email to