kanterov commented on a change in pull request #11074: Store logical type 
values in Row instead of base values
URL: https://github.com/apache/beam/pull/11074#discussion_r389644249
 
 

 ##########
 File path: 
sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/transforms/GroupTest.java
 ##########
 @@ -620,6 +531,88 @@ public void 
testGloballyWithSchemaAggregateFnNestedFields() {
     pipeline.run();
   }
 
+  @DefaultSchema(AutoValueSchema.class)
+  @AutoValue
+  abstract static class BasicEnum {
+    enum Test {
+      ZERO,
+      ONE,
+      TWO
+    };
+
+    abstract String getKey();
+
+    abstract Test getEnumeration();
+
+    static BasicEnum of(String key, Test value) {
+      return new AutoValue_GroupTest_BasicEnum(key, value);
+    }
+  }
+
+  static final EnumerationType BASIC_ENUM_ENUMERATION =
+      EnumerationType.create("ZERO", "ONE", "TWO");
+  static final Schema BASIC_ENUM_SCHEMA =
+      Schema.builder()
+          .addStringField("key")
+          .addLogicalTypeField("enumeration", BASIC_ENUM_ENUMERATION)
+          .build();
+
+  @Test
+  @Category(NeedsRunner.class)
+  public void testAggregateBaseValuesGlobally() {
+    Collection<BasicEnum> elements =
+        Lists.newArrayList(
+            BasicEnum.of("a", BasicEnum.Test.ONE), BasicEnum.of("a", 
BasicEnum.Test.TWO));
+
+    PCollection<Row> aggregate =
+        pipeline
+            .apply(Create.of(elements))
+            .apply(
+                Group.<BasicEnum>globally()
+                    .aggregateFieldBaseValue("enumeration", Sum.ofIntegers(), 
"enum_sum"));
 
 Review comment:
   This looks rather unexpected that Combiner accepts `int` as an argument 
instead of `EnumerationType.Value`

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


With regards,
Apache Git Services

Reply via email to