mihaibudiu commented on code in PR #4543:
URL: https://github.com/apache/calcite/pull/4543#discussion_r2383902735


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java:
##########
@@ -1280,8 +1280,11 @@ public class SqlStdOperatorTable extends 
ReflectiveSqlOperatorTable {
    */
   public static final SqlFunction BITAND =
       SqlBasicFunction.create("BITAND", SqlKind.BITAND,
-          ReturnTypes.LARGEST_INT_OR_FIRST_NON_NULL,
-          OperandTypes.INTEGER_INTEGER.or(OperandTypes.BINARY_BINARY));
+          ReturnTypes.LARGEST_INT_BINARY_OR_LEAST_RESTRICTIVE,

Review Comment:
   I don't think we are allowed to change the behavior of public functions 
unless we can argue that the behavior is a bug. Semantic versioning forbids 
doing this.
   
   Are you fixing a bug here? In that case, maybe we should file an issue about 
this bug and fix if first, before merging the new `&` operator.



##########
core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java:
##########
@@ -1312,6 +1315,23 @@ public class SqlStdOperatorTable extends 
ReflectiveSqlOperatorTable {
           InferTypes.FIRST_KNOWN,
           OperandTypes.INTEGER_INTEGER.or(OperandTypes.BINARY_BINARY)
               .or(OperandTypes.UNSIGNED_NUMERIC_UNSIGNED_NUMERIC));
+  // Both operands should support bitwise operations
+
+  /**
+   * <code>{@code &}</code> operator.
+   */
+  public static final SqlBinaryOperator BITAND_OPERATOR =
+      new SqlBinaryOperator(
+          "&",
+          SqlKind.BITAND,
+          50,        // Higher precedence than XOR but lower than 
multiplication
+          true,
+          ReturnTypes.LARGEST_INT_BINARY_OR_LEAST_RESTRICTIVE,
+          InferTypes.FIRST_KNOWN,
+          OperandTypes.INTEGER_INTEGER.or(OperandTypes.BINARY_BINARY)
+              .or(OperandTypes.UNSIGNED_NUMERIC_UNSIGNED_NUMERIC)
+              .or(OperandTypes.family(SqlTypeFamily.UNSIGNED_NUMERIC, 
SqlTypeFamily.INTEGER)
+                  .or(OperandTypes.family(SqlTypeFamily.INTEGER, 
SqlTypeFamily.UNSIGNED_NUMERIC))));

Review Comment:
   Clearly, BITAND and BITAND_OPERATOR should have the same behavior.
   But I was asking whether the type checking rules match the other bitwise 
operators, such as BITXOR and BITOR.



##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -1266,7 +1266,7 @@ public static SqlSingleOperandTypeChecker same(int 
operandCount,
   public static final SqlSingleOperandTypeChecker DIVISION_OPERATOR =
       NUMERIC_NUMERIC.or(INTERVAL_NUMERIC);
 
-  public static final SqlSingleOperandTypeChecker MINUS_OPERATOR =
+  public static final SqlSingleOperandTypeChecker  MINUS_OPERATOR =

Review Comment:
   please remove the extra space, it shouldn't be there and it adds useless 
work for the reviewer.



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

Reply via email to