Dwrite commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2117583126
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java:
##########
@@ -1299,6 +1299,33 @@ public class SqlStdOperatorTable extends
ReflectiveSqlOperatorTable {
ReturnTypes.LARGEST_INT_OR_FIRST_NON_NULL,
OperandTypes.INTEGER_INTEGER.or(OperandTypes.BINARY_BINARY));
+ /**
+ * <code>{@code ^}</code> operator.
+ */
+ public static final SqlBinaryOperator BITXOR_OPERATOR =
+ new SqlMonotonicBinaryOperator(
+ "^",
+ SqlKind.BITXOR,
+ 50, // Precedence between addition (40) and multiplication
(60)
+ true,
+ ReturnTypes.LARGEST_INT_OR_FIRST_NON_NULL, // Returns same type as
inputs when nullable
+ InferTypes.FIRST_KNOWN,
+ OperandTypes.INTEGER_INTEGER.or(OperandTypes.BINARY_BINARY));
+ // Both operands should support bitwise operations
+
+ /**
+ * <code>{@code <<}</code> operator.
+ */
+ public static final SqlBinaryOperator LEFTSHIFT_OPERATOR =
+ new SqlBinaryOperator("<<", // Operator name
+ SqlKind.OTHER_FUNCTION, // SqlKind
+ 32,
+ true,
+ ReturnTypes.LARGEST_INT_OR_FIRST_NON_NULL,
+ null,
+ OperandTypes.family(SqlTypeFamily.INTEGER, SqlTypeFamily.INTEGER));
Review Comment:
Since Java provides a standard way to handle this overloading, should we
consider reusing that approach directly in this implementation?
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -3226,6 +3226,21 @@ public static ByteString bitNot(ByteString b) {
return new ByteString(result);
}
+ public static int leftShift(int a, int b) {
+ return a << b;
+ }
+
+ public static long leftShift(long a, int b) {
+ return a << b;
+ }
+
+ public static long leftShift(int a, long b) {
+ return a << b;
+ }
+
+ public static long leftShift(Long a, Long b) {
Review Comment:
Since Java provides a standard way to handle this overloading, should we
consider reusing that approach directly in this implementation?
--
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]