Dwrite commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2218144803
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java:
##########
@@ -1298,6 +1298,19 @@ public class SqlStdOperatorTable extends
ReflectiveSqlOperatorTable {
SqlBasicFunction.create("BITXOR", SqlKind.BITXOR,
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 SqlBinaryOperator(
+ "^",
+ SqlKind.BITXOR,
+ 40, // Precedence between addition (40) and multiplication
(60)
+ true,
+ ReturnTypes.LARGEST_INT_OR_FIRST_NON_NULL, // Returns same type as
inputs when nullable
Review Comment:
I've updated the comment to clarify the meaning of FIRST_NON_NULL in this
context — it means that the result type will be derived from the first non-null
operand, which aligns with the behavior in SqlFunction BITXOR.
Regarding mixed types: yes, type coercion is typically expected to ensure
operands are of compatible types. However, since coercion can be disabled in
some configurations, this rule falls back to arithmetic-compatible behavior if
the operand types differ.
Let me know if you'd prefer a different strategy for type derivation here —
happy to adjust.
--
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]