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

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

                Author: ASF GitHub Bot
            Created on: 18/May/20 22:57
            Start Date: 18/May/20 22:57
    Worklog Time Spent: 10m 
      Work Description: omarismail94 commented on a change in pull request 
#11737:
URL: https://github.com/apache/beam/pull/11737#discussion_r426935461



##########
File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/transform/BeamBuiltinAggregations.java
##########
@@ -347,4 +357,35 @@ public BigDecimal toBigDecimal(BigDecimal record) {
       return record;
     }
   }
+
+  static class BitOr<T extends Number> extends CombineFn<T, BitOr.Accum, Long> 
{
+    static class Accum {

Review comment:
       Actually, this might work, let me test this
   ```
     static class BitOr<T extends Number> extends CombineFn<T, Long, Long> {
       @Override
       public Long createAccumulator() {
         return 0L;
       }
   
       @Override
       public Long addInput(Long accum, T input) {
         return accum | input.longValue();
       }
   
       @Override
       public Long mergeAccumulators(Iterable<Long> accums) {
         Long merged = createAccumulator();
         for (Long accum : accums) {
           merged = merged | accum;
         }
         return merged;
       }
   
       @Override
       public Long extractOutput(Long accum) {
         return accum;
       }
     }
   }
   ```

##########
File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/transform/BeamBuiltinAggregations.java
##########
@@ -347,4 +357,35 @@ public BigDecimal toBigDecimal(BigDecimal record) {
       return record;
     }
   }
+
+  static class BitOr<T extends Number> extends CombineFn<T, BitOr.Accum, Long> 
{
+    static class Accum {

Review comment:
       It worked! Will commit this now!




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


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

    Worklog Id:     (was: 434660)
    Time Spent: 2h 10m  (was: 2h)

> Support BIT_OR aggregation function in Beam SQL
> -----------------------------------------------
>
>                 Key: BEAM-9984
>                 URL: https://issues.apache.org/jira/browse/BEAM-9984
>             Project: Beam
>          Issue Type: Task
>          Components: dsl-sql, dsl-sql-zetasql
>            Reporter: Kenneth Knowles
>            Assignee: Omar Ismail
>            Priority: P2
>              Labels: starter
>          Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> Performs a bitwise OR operation on expression and returns the result.
> Supported Argument Types: INT64
> Returned Data Types: INT64
> Examples
> {code:sql}
> SELECT BIT_OR(c) as bit_and FROM UNNEST([0xF001, 0x00A1]) as c;
> +---------+
> | bit_and |
> +---------+
> | 1       |
> +---------+
> {code}
> What is expected: should include both Calcite and ZetaSQL dialects.
> How to test: unit tests
> Reference: 
> https://cloud.google.com/bigquery/docs/reference/standard-sql/aggregate_functions#bit_or



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

Reply via email to