You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/02/17 01:21:00 UTC

[jira] [Work logged] (BEAM-11389) Implement the LOGICAL_AND function for Beam SQL ZetaSQL dialect, as CombineFn.

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

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

                Author: ASF GitHub Bot
            Created on: 17/Feb/21 01:20
            Start Date: 17/Feb/21 01:20
    Worklog Time Spent: 10m 
      Work Description: robinyqiu commented on a change in pull request #13817:
URL: https://github.com/apache/beam/pull/13817#discussion_r577258736



##########
File path: sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/transform/BeamBuiltinAggregations.java
##########
@@ -453,4 +462,57 @@ public Long extractOutput(Accum accum) {
       return accum.bitAnd;
     }
   }
+
+  public static class LogicalAnd extends CombineFn<Boolean, LogicalAnd.Accum, Boolean> {
+    static class Accum {
+      // Initially, input is empty
+      boolean isEmpty = true;
+      // true if any null value is seen in the input, null values are to be ignored
+      boolean isNull = false;
+      // logical_and operation result
+      boolean logicalAnd = Boolean.parseBoolean(null);
+    }
+
+    @Override
+    public Accum createAccumulator() {
+      return new Accum();
+    }
+
+    @Override
+    public Accum addInput(Accum accum, Boolean input) {
+      if (input == null) {
+        accum.isNull = true;
+        accum.isEmpty = false;
+        return accum;
+      }
+      accum.isEmpty = false;
+      accum.logicalAnd = accum.logicalAnd && input;
+      return accum;
+    }
+
+    @Override
+    public Accum mergeAccumulators(Iterable<Accum> accums) {
+      LogicalAnd.Accum merged = createAccumulator();
+      for (LogicalAnd.Accum accum : accums) {
+        if (accum.isNull) {
+          // ignore null case
+          continue;

Review comment:
       Hi @sonam-vend, please see the comment above to fix the problem.




----------------------------------------------------------------
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:
users@infra.apache.org


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

    Worklog Id:     (was: 553302)
    Time Spent: 2.5h  (was: 2h 20m)

> Implement the LOGICAL_AND function for Beam SQL ZetaSQL dialect, as CombineFn.
> ------------------------------------------------------------------------------
>
>                 Key: BEAM-11389
>                 URL: https://issues.apache.org/jira/browse/BEAM-11389
>             Project: Beam
>          Issue Type: Sub-task
>          Components: dsl-sql-zetasql
>            Reporter: Sonam Ramchand
>            Priority: P2
>          Time Spent: 2.5h
>  Remaining Estimate: 0h
>




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