vlsi commented on a change in pull request #1795:
URL: https://github.com/apache/calcite/pull/1795#discussion_r492986042



##########
File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
##########
@@ -1066,12 +1067,53 @@ private static RuntimeException notComparable(String 
op, Object b0,
         op, b1.getClass().toString()).ex();
   }
 
-  // &
-  /** Helper function for implementing <code>BIT_AND</code> */
+  // BITAND
+
+  /** SQL <code>BITAND</code> operator applied to long values */
   public static long bitAnd(long b0, long b1) {
     return b0 & b1;
   }
 
+  /** SQL <code>BITAND</code> operator applied to ByteString values */
+  public static ByteString bitAnd(ByteString b0, ByteString b1) {
+
+    if (b0.length() != b1.length()) {
+      throw RESOURCE.invalidInputForBitwiseBinaryValue().ex();
+    }
+    byte[] bytes0 = b0.getBytes();
+    byte[] bytes1 = b1.getBytes();
+    byte[] result = new byte[b0.length()];
+
+    IntStream.range(0, bytes0.length).forEach(i -> {

Review comment:
       Frankly speaking, a good old `for` loop would look better here, and it 
looks like streams add complexity without much benefits.
   ```suggestion
       for (int i = 0; i < bytes0.length; i++) {
   ```




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


Reply via email to