danny0405 commented on a change in pull request #1878: [CALCITE-3782]Bitwise 
agg operator Bit_And, Bit_OR and Bit_XOR support binary and varbinary type
URL: https://github.com/apache/calcite/pull/1878#discussion_r399613856
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
 ##########
 @@ -1074,23 +1075,83 @@ private static RuntimeException notComparable(String 
op, Object b0,
   }
 
   // &
-  /** Helper function for implementing <code>BIT_AND</code> */
+  /** Helper function for implementing <code>BIT_AND</code> applied to integer 
values */
   public static long bitAnd(long b0, long b1) {
     return b0 & b1;
   }
 
+  /** Helper function for implementing <code>BIT_AND</code> applied to binary 
values */
+  public static ByteString bitAnd(ByteString b0, ByteString b1) {
+
+    if (b0.length() == 0 || b1.length() == 0) {
+      return b1.length() == 0 ? b0 : b1;
+    }
+
 
 Review comment:
   The code below seems more straight-forward.
   ```java
   if (b0.length() == 0) {
         return b1;
   }
   
   if (b1.length() == 0) {
       return b0;
   }
   ```

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