NobiGo commented on code in PR #3927:
URL: https://github.com/apache/calcite/pull/3927#discussion_r1732364911
##########
site/_docs/reference.md:
##########
@@ -2752,6 +2752,11 @@ In the following:
| * | ATANH(numeric) | Returns the inverse
hyperbolic tangent of *numeric*
| f | BITAND_AGG(value) | Equivalent to
`BIT_AND(value)`
| f | BITOR_AGG(value) | Equivalent to
`BIT_OR(value)`
+| * | BITCOUNT(integer) | Returns the bitwise
COUNT of *integer* or NULL if *integer* is NULL
+| * | BITCOUNT(binary) | Returns the bitwise
COUNT of *binary* of NULL if *binary* is NULL
Review Comment:
Merge these two functions into one?
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -2834,6 +2834,42 @@ public static ByteString bitAnd(ByteString b0,
ByteString b1) {
return binaryOperator(b0, b1, (x, y) -> (byte) (x & y));
}
+ /** Helper function for implementing <code>BITCOUNT</code>. Counts the number
+ * of bits set in an integer value. */
+ public static long bitCount(long b) {
+ return Long.bitCount(b);
+ }
+
+ private static final BigDecimal BITCOUNT_MAX = new
BigDecimal("18446744073709551615");
Review Comment:
Why this number?
--
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]