[ 
https://issues.apache.org/jira/browse/BEAM-12100?focusedWorklogId=646520&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-646520
 ]

ASF GitHub Bot logged work on BEAM-12100:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Sep/21 23:22
            Start Date: 03/Sep/21 23:22
    Worklog Time Spent: 10m 
      Work Description: benWize commented on a change in pull request #15174:
URL: https://github.com/apache/beam/pull/15174#discussion_r702196988



##########
File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/transform/BeamBuiltinAggregations.java
##########
@@ -163,6 +167,32 @@ static CombineFn createSum(Schema.FieldType fieldType) {
     }
   }
 
+  /**
+   * {@link CombineFn} for Sum0 where sum of null returns 0 based on {@link 
Sum} and {@link
+   * Combine.BinaryCombineFn}.
+   */
+  static CombineFn createSum0(Schema.FieldType fieldType) {
+    switch (fieldType.getTypeName()) {
+      case INT32:
+        return new IntegerSum0();
+      case INT16:
+        return new ShortSum0();
+      case BYTE:
+        return new ByteSum0();
+      case INT64:
+        return new LongSum0();
+      case FLOAT:
+        return new FloatSum0();
+      case DOUBLE:
+        return new DoubleSum0();
+      case DECIMAL:
+        return new BigDecimalSum0();
+      default:
+        throw new UnsupportedOperationException(
+            String.format("[%s] is not supported in SUM", fieldType));

Review comment:
       Fixed




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 646520)
    Time Spent: 8h 10m  (was: 8h)

> SUM should error when overflow/underflow occurs.
> ------------------------------------------------
>
>                 Key: BEAM-12100
>                 URL: https://issues.apache.org/jira/browse/BEAM-12100
>             Project: Beam
>          Issue Type: Bug
>          Components: dsl-sql-zetasql
>            Reporter: Kyle Weaver
>            Assignee: Benjamin Gonzalez
>            Priority: P3
>          Time Spent: 8h 10m
>  Remaining Estimate: 0h
>
> SELECT SUM(col1) FROM (SELECT CAST(9223372036854775807 as int64) as col1 
> UNION ALL SELECT CAST(1 as int64))
> should return an error.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to