You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "Dwrite (via GitHub)" <gi...@apache.org> on 2025/04/27 09:18:43 UTC

[PR] Krooswu/new operators [calcite]

Dwrite opened a new pull request, #4339:
URL: https://github.com/apache/calcite/pull/4339

   (no comment)


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ ,<<, & operators and RightShift sqlFunction [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
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:
   Just add more test cases. 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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3115313188

   I think this signals a bug in the testing framework, I will take a look at this.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3123894783

   > I have pushed an extra commit which should fix the problems of the test framework with carets. It would be nice if someone else than me could review that. It was a bit messy to cleanup.
   > 
   > (I have also removed your custom caret parsing function)
   
   sure. I just asked the `[xuzifu666](https://github.com/xuzifu666)` to review


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2218153344


##########
core/src/main/java/org/apache/calcite/sql/parser/StringAndPos.java:
##########
@@ -52,8 +53,54 @@ private StringAndPos(String sql, int cursor, @Nullable SqlParserPos pos) {
   }
 
   /**
-   * Looks for one or two carets in a SQL string, and if present, converts
-   * them into a parser position.
+   * Checks if the SQL expression is a simple XOR pattern that can be safely processed.
+   *
+   * <p>This method provides special handling for the BITXOR_OPERATOR (^) in Apache Calcite

Review Comment:
   I totally understand the concern about adding too many special patterns potentially making the test input language confusing.
   
   However, after careful consideration and multiple attempts, this approach with these specific patterns is currently the simplest way to guarantee idempotency of the of(String sql) method and keep all existing test cases passing.
   
   Simply treating a single caret ^ as a normal character unfortunately breaks certain tests that rely on caret-based highlighting for error ranges.
   
   If you have any alternative approach that can keep idempotency and pass all tests without introducing these patterns, I’d be very glad to explore it together!



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3111833608

   java.lang.RuntimeException: Error while parsing query: values (2 ^^ 3)
   
   	at org.apache.calcite.sql.test.AbstractSqlTester.parseAndValidate(AbstractSqlTester.java:158)
   	at org.apache.calcite.sql.test.AbstractSqlTester.check(AbstractSqlTester.java:240)
   	at org.apache.calcite.sql.test.SqlTester.check(SqlTester.java:158)
   	at org.apache.calcite.test.SqlOperatorFixtureImpl.lambda$checkScalar$2(SqlOperatorFixtureImpl.java:240)
   	at org.apache.calcite.sql.test.AbstractSqlTester.forEachQuery(AbstractSqlTester.java:454)
   	at org.apache.calcite.test.SqlOperatorFixtureImpl.checkScalar(SqlOperatorFixtureImpl.java:239)
   	at org.apache.calcite.sql.test.SqlOperatorFixture.checkScalar(SqlOperatorFixture.java:232)
   	at org.apache.calcite.test.SqlOperatorTest.testBitXorOperatorScalarFunc(SqlOperatorTest.java:16468)
   	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
   	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
   	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
   	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
   	at 
   ....
   Caused by: org.apache.calcite.sql.parser.SqlParseException: Encountered "^ ^" at line 1, column 11.
   
   Hi,
   
   Just to clarify, Quidem replaces ^^ with a single caret ^ before executing the tests. So in test inputs, we need to write ^^ to represent an actual caret.
   
   The issue is that this replacement happens multiple times during test processing, which means the caret count reduces each time the test runs. This breaks idempotency, because the SQL changes after the first run, causing failures or unexpected behavior on subsequent runs.
   
   That’s why relying solely on doubling carets (^^) isn’t an ideal solution. We need a way to handle single carets properly to ensure consistent behavior across multiple executions.
   
   Thanks for understanding!
   
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3134767500

   > Please squash the commits so we can merge. If it's not too much work, you can leave my changes in a separate commit - but that may be difficult.
   
   Thanks for the review! I've squashed my commits and kept your fixes in a separate commit as suggested.
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3140618076

   Appreciate your patience with the long review process


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3116410083

   Let’s wait a bit. Thank you


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ and << operators [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2835630540

   @NobiGo hi, thanks for your time. already add relevant descriptions to Jira. I have currently implemented support for the ^ (bitwise XOR) and << (bitwise left shift) operators. However, due to the testing framework using {^} as a parser position. I have only added a parser test for it, and I need find new test for it. do you have some suggestions ?


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ and << operators [calcite]

Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2833859052

   @Dwrite please ensure that the Commit info in the PR is consistent with the Jira summary. If the PR has implemented "<<", please add relevant descriptions in Jira.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2995619027

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2218133530


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -3417,6 +3417,66 @@ public static ByteString bitNot(ByteString b) {
     return new ByteString(result);
   }
 
+  /**
+   * Bitwise function <code>BITXOR</code> applied to {@link Long} values.
+   * Returns {@code 0L} if any operand is null.
+   */
+  public static long bitXor(Long b0, Long b1) {
+    return (b0 == null || b1 == null)
+        ? 0L
+        : b0 ^ b1;
+  }
+
+  /**
+   * Bitwise function <code>BITXOR</code> applied to {@link Integer} values.
+   * Returns {@code 0L} if any operand is null.
+   */
+  public static long bitXor(Integer b0, Integer b1) {
+    return (b0 == null || b1 == null)
+        ? 0L
+        : b0 ^ b1;
+  }
+
+  /**
+   * Bitwise function <code>BITXOR</code> applied to {@link org.joou.UByte} values.
+   * Returns {@code null} if any operand is null.
+   */
+  public static @PolyNull UByte bitXor(@PolyNull UByte b0, @PolyNull UByte b1) {
+    return (b0 == null || b1 == null)
+        ? castNonNull(null)
+        : UByte.valueOf(b0.shortValue() ^ b1.shortValue());
+  }
+
+  /**
+   * Bitwise function <code>BITXOR</code> applied to {@link org.joou.UShort} values.
+   * Returns {@code null} if any operand is null.
+   */
+  public static @PolyNull UShort bitXor(@PolyNull UShort b0, @PolyNull UShort b1) {
+    return (b0 == null || b1 == null)
+        ? castNonNull(null)
+        : UShort.valueOf(b0.intValue() ^ b1.intValue());
+  }
+
+  /**
+   * Bitwise function <code>BITXOR</code> applied to {@link org.joou.UInteger} values.
+   * Returns {@code null} if any operand is null.
+   */
+  public static @PolyNull UInteger bitXor(@PolyNull UInteger b0, @PolyNull UInteger b1) {
+    return (b0 == null || b1 == null)
+        ? castNonNull(null)
+        : UInteger.valueOf(b0.longValue() ^ b1.longValue());
+  }
+
+  /**
+   * Bitwise function <code>BITXOR</code> applied to {@link org.joou.ULong} values.
+   * Returns {@code null} if any operand is null.
+   */
+  public static @PolyNull ULong bitXor(@PolyNull ULong b0, @PolyNull ULong b1) {
+    return (b0 == null || b1 == null)
+        ? castNonNull(null)
+        : ULong.valueOf(b0.longValue() ^ b1.longValue());

Review Comment:
   Added.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2217289834


##########
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:
   Thanks for raising this — great point.
   
   You're right that FIRST_NON_NULL can be a bit ambiguous. My understanding is that LARGEST_INT_OR_FIRST_NON_NULL behaves like:
   
   If both inputs are integer types (including unsigned ones), it returns the "largest" type that can hold both.
   
   If either is NULL, and inference is based on that input alone, it falls back to the type of the first non-null argument.
   
   It's a safeguard when type coercion is disabled or incomplete.
   
   In theory, with coercion enabled, inputs should be normalized to the same type (e.g., INTEGER ^ BIGINT becomes BIGINT ^ BIGINT). But when coercion is off, this return type inference helps prevent type mismatch errors and makes the behavior consistent for combinations like UByte ^ Integer, which we've added support for.
   
   Also, I’ve updated the comment to make this behavior clearer in the code.
   
   That said, I agree this return type logic may benefit from being aligned more closely with arithmetic rules. If there’s a more precise or canonical way to represent this (e.g., a custom inference rule or a cleaned-up version of LARGEST_INT_OR_FIRST_NON_NULL), I’d be happy to experiment with it.
   
   Let me know if you’d prefer I try that here or in a follow-up.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ and << operators [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2067797371


##########
core/src/main/codegen/templates/Parser.jj:
##########
@@ -7920,6 +7920,7 @@ SqlBinaryOperator BinaryRowOperator() :
 {
     // <IN> is handled as a special case
     <EQ> { return SqlStdOperatorTable.EQUALS; }
+|   <LEFTSHIFT> { return SqlStdOperatorTable.LEFTSHIFT_OPERATOR; }

Review Comment:
   yeah. I am trying to add it, But I need to resolve this parsing conflict with `cast(a as map<varchar multiset, map<int, int>>)`



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ and << operators [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2848655627

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [94.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3095180352

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [61.8% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.4% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3122191200

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [5 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [77.3% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1.2% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2162052645


##########
core/src/main/java/org/apache/calcite/sql/parser/StringAndPos.java:
##########
@@ -65,6 +101,10 @@ private StringAndPos(String sql, int cursor, @Nullable SqlParserPos pos) {
    * </ul>
    */
   public static StringAndPos of(String sql) {
+
+    if (BITXOR_OPERATOR_WHITELISTED_SQLS.contains(sql)) {

Review Comment:
   the right way to do this is to introduce an escape mechanism, similar to escaping quotes in strings
   For example, parse ^^ into a ^ in StringAndPos.
   If you do that, please add test cases for the StringAndPos parser.
   



##########
core/src/main/java/org/apache/calcite/sql/parser/StringAndPos.java:
##########
@@ -28,6 +31,39 @@ public class StringAndPos {
   public final String sql;
   public final int cursor;
   public final @Nullable SqlParserPos pos;
+  private static final Set<String> BITXOR_OPERATOR_WHITELISTED_SQLS;
+
+  static {

Review Comment:
   are these test cases?
   they do not belong to this class; they should in a test package



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ ,<<, & operators and RightShift sqlFunction [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2924775814

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [80.4% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [14.6% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ ,<<, & operators and RightShift sqlFunction [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2868169317

   The code to parse the string and carets is hand-written, the right solution is indeed to adapt it to treat a double caret as an escaped caret. (or some other similar escaping mechanism.)


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3117325453

   > Let’s wait a bit. Thank you
   
   Sure, thanks!
   Just to mention — I’ve added the previously discussed << operator in a separate PR: https://github.com/apache/calcite/pull/4478.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3107403245

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [65.9% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.4% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ and << operators [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2073540503


##########
core/src/main/codegen/templates/Parser.jj:
##########
@@ -7920,6 +7920,7 @@ SqlBinaryOperator BinaryRowOperator() :
 {
     // <IN> is handled as a special case
     <EQ> { return SqlStdOperatorTable.EQUALS; }
+|   <LEFTSHIFT> { return SqlStdOperatorTable.LEFTSHIFT_OPERATOR; }

Review Comment:
   still can not fix this conflict. wii add RIGHTSHIFT function to support.



##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -16294,6 +16299,51 @@ private static void checkLogicalOrFunc(SqlOperatorFixture f) {
     f.checkAgg("logical_or(x)", values4, isNullValue());
   }
 
+  @Test void testBitXorOperatorScalarFunc() throws SqlParseException {
+    String sql = "SELECT 5 ^ 3 ";
+    SqlNode sqlNode = SqlParser.create(sql,  SqlParser.Config.DEFAULT).parseStmt();
+
+    assertInstanceOf(SqlSelect.class, sqlNode);
+    SqlSelect select = (SqlSelect) sqlNode;
+
+    SqlNode selectItem = select.getSelectList().get(0);
+    assertInstanceOf(SqlBasicCall.class, selectItem);
+    SqlBasicCall call = (SqlBasicCall) selectItem;
+    assertEquals(SqlStdOperatorTable.BITXOR_OPERATOR, call.getOperator());
+    assertEquals(2, call.getOperandList().size());
+  }
+
+  @Test void testLeftShiftScalarFunc() {
+    final SqlOperatorFixture f = fixture();
+    f.setFor(SqlStdOperatorTable.LEFTSHIFT_OPERATOR, VmName.EXPAND);
+
+
+    // Basic test cases
+    f.checkScalar("2 << 2", "8", "INTEGER NOT NULL");

Review Comment:
   Just add more test cases. 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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2213658815


##########
core/src/main/java/org/apache/calcite/sql/parser/StringAndPos.java:
##########
@@ -65,6 +101,10 @@ private StringAndPos(String sql, int cursor, @Nullable SqlParserPos pos) {
    * </ul>
    */
   public static StringAndPos of(String sql) {
+
+    if (BITXOR_OPERATOR_WHITELISTED_SQLS.contains(sql)) {

Review Comment:
   Thanks for the suggestion!
   
   I've updated the implementation to support an escape mechanism in StringAndPos, where ^^ is parsed into a single ^, similar to quote escaping.
   I also added corresponding test cases in StringAndPosTest to verify the behavior.
   
   Let me know if you have any further comments — would appreciate another round of review when you have a chance.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ and << operators [calcite]

Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2067724076


##########
core/src/main/codegen/templates/Parser.jj:
##########
@@ -7920,6 +7920,7 @@ SqlBinaryOperator BinaryRowOperator() :
 {
     // <IN> is handled as a special case
     <EQ> { return SqlStdOperatorTable.EQUALS; }
+|   <LEFTSHIFT> { return SqlStdOperatorTable.LEFTSHIFT_OPERATOR; }

Review Comment:
   Just curious,should we also need to implement RIGHTSHIFT? 



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ ,<<, & operators and RightShift sqlFunction [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2982300788

   The PR title does not match the issue; please edit the issue.
   In general, I think it's preferable to solve one problem in one PR, so probably this one should be 3 separate PRs (and 3 issues).
   But I will review it as it is.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3138467903

   > If you will change the commits, maybe you can combine the two changes from the first two commits into a single one and use that message.
   sure. Just squash the commits to one commit.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2238176161


##########
core/src/main/java/org/apache/calcite/materialize/TileSuggester.java:
##########
@@ -60,11 +60,11 @@ public Iterable<? extends Lattice.Tile> tiles() {
     final double f = statisticsProvider.getFactRowCount();
     final ImmutableMap.Builder<Parameter, Object> map = ImmutableMap.builder();
     if (lattice.algorithmMaxMillis >= 0) {
-      map.put(Algorithm.ParameterEnum.timeLimitSeconds,
+      map.put(Algorithm.ParameterEnum.TIME_LIMIT_SECONDS,

Review Comment:
   sure.updated



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3130432337

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [5 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [66.9% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3136985748

   I think there is a linter rule which will prohibit you from having a commit message starting with "Fix".
   You can try to run this locally with ./gradlew build.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3138496906

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [5 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [66.9% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ ,<<, & operators and RightShift sqlFunction [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2980510472

   @mihaibudiu 
   Thanks for checking in! The current status is that the PR adds support for the ^, <<, and & operators, as well as the RightShift function. I've added complete test cases for all of them except for ^, which is currently tested using a whitelist-based approach, since writing exhaustive tests for it is relatively complex.
   
   Could you help review whether this approach for ^ is acceptable?


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ ,<<, & operators and RightShift sqlFunction [calcite]

Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2868168045

   > @NobiGo hi, thanks for your time. already add relevant descriptions to Jira. I have currently implemented support for the ^ (bitwise XOR) and << (bitwise left shift) operators. However, due to the testing framework using {^} as a parser position. I have only added a parser test for it, and I need find new test for it. do you have some suggestions ?
   
   I haven't carefully read the implementation logic of `^` in the test cases. I wonder if there are escape characters to distinguish it?


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3100803497

   > I will wait for an iq test to finish reviewing.
   Added  The iq test.
   The reason idempotency is broken is not because of ^^ sequences (which are already handled), but due to this specific logic:
   else if (secondCaret < 0) {
     String sqlSansCaret =
         sql.substring(0, firstCaret)
             + sql.substring(firstCaret + 1);
     ...
   }
   This block assumes that a single ^ in the SQL string is always an error marker, and removes it. However, in valid SQL expressions such as SELECT 2 ^ 3, the caret is actually a legitimate binary operator (bitwise XOR). As a result, writing a test like this and running QuidemTest will strip the caret — breaking the SQL and making the test output non-idempotent.
   
   That’s why the fix needs to distinguish between carets used as error markers versus those used as operators. Without that, tests using XOR will be incorrectly processed and fail on rerun.
   
   Escaping every caret manually (^^) would work, but that’s a workaround, not a real solution — it hurts test readability and burdens contributors unnecessarily. The fix I propose aims to retain natural SQL input and preserve idempotent behavior.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3100957366

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [61.8% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.4% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2216541734


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -3417,6 +3417,66 @@ public static ByteString bitNot(ByteString b) {
     return new ByteString(result);
   }
 
+  /**
+   * Bitwise function <code>BITXOR</code> applied to {@link Long} values.
+   * Returns {@code 0L} if any operand is null.
+   */
+  public static long bitXor(Long b0, Long b1) {
+    return (b0 == null || b1 == null)
+        ? 0L
+        : b0 ^ b1;
+  }
+
+  /**
+   * Bitwise function <code>BITXOR</code> applied to {@link Integer} values.
+   * Returns {@code 0L} if any operand is null.
+   */
+  public static long bitXor(Integer b0, Integer b1) {
+    return (b0 == null || b1 == null)
+        ? 0L
+        : b0 ^ b1;
+  }
+
+  /**
+   * Bitwise function <code>BITXOR</code> applied to {@link org.joou.UByte} values.
+   * Returns {@code null} if any operand is null.
+   */
+  public static @PolyNull UByte bitXor(@PolyNull UByte b0, @PolyNull UByte b1) {
+    return (b0 == null || b1 == null)
+        ? castNonNull(null)
+        : UByte.valueOf(b0.shortValue() ^ b1.shortValue());
+  }
+
+  /**
+   * Bitwise function <code>BITXOR</code> applied to {@link org.joou.UShort} values.
+   * Returns {@code null} if any operand is null.
+   */
+  public static @PolyNull UShort bitXor(@PolyNull UShort b0, @PolyNull UShort b1) {
+    return (b0 == null || b1 == null)
+        ? castNonNull(null)
+        : UShort.valueOf(b0.intValue() ^ b1.intValue());
+  }
+
+  /**
+   * Bitwise function <code>BITXOR</code> applied to {@link org.joou.UInteger} values.
+   * Returns {@code null} if any operand is null.
+   */
+  public static @PolyNull UInteger bitXor(@PolyNull UInteger b0, @PolyNull UInteger b1) {
+    return (b0 == null || b1 == null)
+        ? castNonNull(null)
+        : UInteger.valueOf(b0.longValue() ^ b1.longValue());
+  }
+
+  /**
+   * Bitwise function <code>BITXOR</code> applied to {@link org.joou.ULong} values.
+   * Returns {@code null} if any operand is null.
+   */
+  public static @PolyNull ULong bitXor(@PolyNull ULong b0, @PolyNull ULong b1) {
+    return (b0 == null || b1 == null)
+        ? castNonNull(null)
+        : ULong.valueOf(b0.longValue() ^ b1.longValue());

Review Comment:
   I hope this handles values that overflow correctly.
   Is there a test for this case (Unsigned value > INT_MAX)



##########
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 am not sure what FIRST_NON_NULL means, and the comment makes it even more ambiguous.
   - can the inputs have different types? Type coercion should make sure that does not happen, but it's not always on 
   - for different types I expect that the rules for arithmetic could apply here too



##########
testkit/src/test/java/org/apache/calcite/test/StringAndPosTest.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.test;
+
+import org.apache.calcite.sql.parser.StringAndPos;
+
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasToString;
+
+/**
+ * Unit tests for {@link StringAndPos}, particularly around caret handling.
+ */
+public class StringAndPosTest {

Review Comment:
   if you don't add these special parsing rules, these tests are no longer necessary either.



##########
core/src/main/java/org/apache/calcite/sql/parser/StringAndPos.java:
##########
@@ -52,8 +53,54 @@ private StringAndPos(String sql, int cursor, @Nullable SqlParserPos pos) {
   }
 
   /**
-   * Looks for one or two carets in a SQL string, and if present, converts
-   * them into a parser position.
+   * Checks if the SQL expression is a simple XOR pattern that can be safely processed.
+   *
+   * <p>This method provides special handling for the BITXOR_OPERATOR (^) in Apache Calcite

Review Comment:
   Let me explain why I think these patterns are not a good idea: they essentially define a weird language for writing StringAndPos strings, whose rules cannot be summarized concisely for users. I'd rather have a simple precise language less convenient for users than a weird one.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2217289834


##########
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:
   Thanks for raising this — great point.
   
   You're right that FIRST_NON_NULL can be a bit ambiguous. My understanding is that LARGEST_INT_OR_FIRST_NON_NULL behaves like:
   
   If both inputs are integer types (including unsigned ones), it returns the "largest" type that can hold both.
   
   If either is NULL, and inference is based on that input alone, it falls back to the type of the first non-null argument.
   
   It's a safeguard when type coercion is disabled or incomplete.
   
   In theory, with coercion enabled, inputs should be normalized to the same type (e.g., INTEGER ^ BIGINT becomes BIGINT ^ BIGINT). But when coercion is off, this return type inference helps prevent type mismatch errors and makes the behavior consistent for combinations like UByte ^ Integer, which we've added support for.
   
   Also, I’ve updated the comment to make this behavior clearer in the code.
   
   That said, I agree this return type logic may benefit from being aligned more closely with arithmetic rules. If there’s a more precise or canonical way to represent this (e.g., a custom inference rule or a cleaned-up version of LARGEST_INT_OR_FIRST_NON_NULL), I’d be happy to experiment with it.
   
   Let me know if you’d prefer I try that here or in a follow-up.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3088924767

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [95.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.8% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3111778557

   Hi mihaibudiu, all checks have passed. May I ask if there's anything missing or any concerns that are blocking approval at this point? I'd be happy to address them. Thanks!


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ ,<<, & operators and RightShift sqlFunction [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2868937735

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [78.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [17.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3115384278

   The problem is the following: the testing framework uses a "consumer" to check the results, with the same API used for negative and positive test cases. There is an implicit assumption that only negative tests may have carets in the SQL strings. So when a positive test is executed, the code paths for handling escaped carets are never executed. I will see whether I can fix this.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2215815937


##########
core/src/main/java/org/apache/calcite/sql/parser/StringAndPos.java:
##########
@@ -52,8 +53,54 @@ private StringAndPos(String sql, int cursor, @Nullable SqlParserPos pos) {
   }
 
   /**
-   * Looks for one or two carets in a SQL string, and if present, converts
-   * them into a parser position.
+   * Checks if the SQL expression is a simple XOR pattern that can be safely processed.
+   *
+   * <p>This method provides special handling for the BITXOR_OPERATOR (^) in Apache Calcite

Review Comment:
   Thanks for the suggestion!
   
   However, simply treating a string with a single caret (^) as a literal character won't work in practice — it causes some of our test cases to fail, particularly those involving parsing or validation errors where caret-based range highlighting is required.
   
   That’s why we use patterns like ^...^ or more structured escape sequences — they provide clarity and work consistently across different test scenarios.
   
   Happy to adjust the pattern matching logic if you have a concrete suggestion that avoids this ambiguity, but we do need some kind of disambiguation.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3097474692

   ```
   $ find . -name *.iq
   ./core/src/test/resources/sql/measure-paper.iq
   ./core/src/test/resources/sql/unnest.iq
   ./core/src/test/resources/sql/sequence.iq
   ./core/src/test/resources/sql/planner.iq
   ./core/src/test/resources/sql/unsigned.iq
   ./core/src/test/resources/sql/winagg.iq
   ./core/src/test/resources/sql/agg.iq
   ...
   ```


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2220557986


##########
core/src/main/java/org/apache/calcite/sql/parser/StringAndPos.java:
##########
@@ -52,8 +53,54 @@ private StringAndPos(String sql, int cursor, @Nullable SqlParserPos pos) {
   }
 
   /**
-   * Looks for one or two carets in a SQL string, and if present, converts
-   * them into a parser position.
+   * Checks if the SQL expression is a simple XOR pattern that can be safely processed.
+   *
+   * <p>This method provides special handling for the BITXOR_OPERATOR (^) in Apache Calcite

Review Comment:
   I am not sure why idempotency is important.
   If I understand right, the function already supports escaping carets
   What's so bad in escaping all carets in the tests for XOR?



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ ,<<, & operators and RightShift sqlFunction [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2924763280

   @NobiGo Is it OK to add some ^ test cases using a whitelist?


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3106482766

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [61.8% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.4% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2238085742


##########
core/src/main/java/org/apache/calcite/materialize/TileSuggester.java:
##########
@@ -60,11 +60,11 @@ public Iterable<? extends Lattice.Tile> tiles() {
     final double f = statisticsProvider.getFactRowCount();
     final ImmutableMap.Builder<Parameter, Object> map = ImmutableMap.builder();
     if (lattice.algorithmMaxMillis >= 0) {
-      map.put(Algorithm.ParameterEnum.timeLimitSeconds,
+      map.put(Algorithm.ParameterEnum.TIME_LIMIT_SECONDS,

Review Comment:
   why are these changes in the diff?
   Can you please rebase on the latest main and force-push again?



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3116302310

   > The problem is the following: the testing framework uses a "consumer" to check the results, with the same API used for negative and positive test cases. There is an implicit assumption that only negative tests may have carets in the SQL strings. So when a positive test is executed, the code paths for handling escaped carets are never executed. I will see whether I can fix this.
   
   Got it, thanks again for the explanation! Just to confirm — would you suggest I hold off on this PR until the testing framework is updated, or is there anything you'd prefer me to adjust in the meantime?


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3141828949

   > Appreciate your patience with the long review process
   
   Thank you! This is actually my first PR to Calcite, and I really appreciate your patience and detailed guidance throughout the long review process. I’ve learned a lot from it. Looking forward to contributing more and doing better in the future!


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ and << operators [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2834054811

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [94.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ ,<<, & operators and RightShift sqlFunction [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2867024473

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [78.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [17.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3111790774

   Can you show me a test that has problems with double carets? Would be good to understand what is going on


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2224736540


##########
core/src/test/resources/sql/operator.iq:
##########
@@ -702,4 +702,54 @@ FOO BOOLEAN(1) NOT NULL
 
 !ok
 
+SELECT 2 ^ 3 AS foo;

Review Comment:
   Thanks for the suggestion! I’ve added non-constant IQ tests with mixed operand types (e.g., empno ^ mgr). Hope this looks good now — happy to adjust further if needed.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3125008012

   > > I have pushed an extra commit which should fix the problems of the test framework with carets. It would be nice if someone else than me could review that. It was a bit messy to cleanup.
   > > (I have also removed your custom caret parsing function)
   > 
   > sure. I just asked the `[xuzifu666](https://github.com/xuzifu666)` to review
   
   I think these changes are fine.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3084613229

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [95.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.8% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2223965561


##########
core/src/test/resources/sql/operator.iq:
##########
@@ -702,4 +702,54 @@ FOO BOOLEAN(1) NOT NULL
 
 !ok
 
+SELECT 2 ^ 3 AS foo;

Review Comment:
   these tests are all tests with constants, please add some non-constant tests, e.g., using empno/empid.
   Also, please mix operand types.
   That's the whole point of iq test - they can run on table data. Better coverage than operator tests.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3105046059

   I think that doubling a caret is something much simpler for contributors to do to write tests than to understand the rules about when a single caret works and when a double one is required.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2218118862


##########
testkit/src/test/java/org/apache/calcite/test/StringAndPosTest.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.test;
+
+import org.apache.calcite.sql.parser.StringAndPos;
+
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasToString;
+
+/**
+ * Unit tests for {@link StringAndPos}, particularly around caret handling.
+ */
+public class StringAndPosTest {

Review Comment:
   deleted



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3095210147

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [61.8% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.4% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3136987906

   If you will change the commits, maybe you can combine the two changes from the first two commits into a single one and use that message.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3134767490

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [5 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [66.9% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3134754794

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [5 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [66.9% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ ,<<, & operators and RightShift sqlFunction [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ ,<<, & operators and RightShift sqlFunction [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2977512739

   What is the status of this PR?


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ ,<<, & operators and RightShift sqlFunction [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2978852696

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [83.1% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [14.4% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2995544341

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ operator [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2995498831

   @mihaibudiu  
   Thanks for the suggestion. I've split this PR as requested.
   - This PR now only supports `^` as per CALCITE-6731


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ and << operators [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-2863532347

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [90.6% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.5% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu merged PR #4339:
URL: https://github.com/apache/calcite/pull/4339


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Added support for ^ and << operators [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2064038850


##########
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:
   will this cover all supported types, like TINYINT?
   What is the semantics of shift when the shift amount is negative or larger than the value size?
   



##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -16294,6 +16299,51 @@ private static void checkLogicalOrFunc(SqlOperatorFixture f) {
     f.checkAgg("logical_or(x)", values4, isNullValue());
   }
 
+  @Test void testBitXorOperatorScalarFunc() throws SqlParseException {
+    String sql = "SELECT 5 ^ 3 ";
+    SqlNode sqlNode = SqlParser.create(sql,  SqlParser.Config.DEFAULT).parseStmt();
+
+    assertInstanceOf(SqlSelect.class, sqlNode);
+    SqlSelect select = (SqlSelect) sqlNode;
+
+    SqlNode selectItem = select.getSelectList().get(0);
+    assertInstanceOf(SqlBasicCall.class, selectItem);
+    SqlBasicCall call = (SqlBasicCall) selectItem;
+    assertEquals(SqlStdOperatorTable.BITXOR_OPERATOR, call.getOperator());
+    assertEquals(2, call.getOperandList().size());
+  }
+
+  @Test void testLeftShiftScalarFunc() {
+    final SqlOperatorFixture f = fixture();
+    f.setFor(SqlStdOperatorTable.LEFTSHIFT_OPERATOR, VmName.EXPAND);
+
+
+    // Basic test cases
+    f.checkScalar("2 << 2", "8", "INTEGER NOT NULL");

Review Comment:
   can you test with values out of range 
   - overflows caused by <<
   - shift amount too large
   - shift amount negative



##########
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:
   are you sure that any integer type is fine? This creates a very large number of configurations. I would expect that at least the shift amount does not support all integer types.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2213944947


##########
core/src/main/java/org/apache/calcite/sql/parser/StringAndPos.java:
##########
@@ -52,8 +53,54 @@ private StringAndPos(String sql, int cursor, @Nullable SqlParserPos pos) {
   }
 
   /**
-   * Looks for one or two carets in a SQL string, and if present, converts
-   * them into a parser position.
+   * Checks if the SQL expression is a simple XOR pattern that can be safely processed.
+   *
+   * <p>This method provides special handling for the BITXOR_OPERATOR (^) in Apache Calcite

Review Comment:
   I think these patterns are overly specific and not really that useful just for allowing people to skip one caret in a test case.
   If you really want special processing, you could treat a string with a single caret specially, by interpreting the caret as a normal character.



##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -16294,6 +16299,48 @@ private static void checkLogicalOrFunc(SqlOperatorFixture f) {
     f.checkAgg("logical_or(x)", values4, isNullValue());
   }
 
+  @Test void testBitXorOperatorParserFunc() throws SqlParseException {
+    String sql = "SELECT 5 ^ 3 ";
+    SqlNode sqlNode = SqlParser.create(sql,  SqlParser.Config.DEFAULT).parseStmt();
+
+    assertInstanceOf(SqlSelect.class, sqlNode);
+    SqlSelect select = (SqlSelect) sqlNode;
+
+    SqlNode selectItem = select.getSelectList().get(0);
+    assertInstanceOf(SqlBasicCall.class, selectItem);
+    SqlBasicCall call = (SqlBasicCall) selectItem;
+    assertEquals(SqlStdOperatorTable.BITXOR_OPERATOR, call.getOperator());
+    assertEquals(2, call.getOperandList().size());
+  }
+
+  @Test void testBitXorOperatorScalarFunc() {
+    final SqlOperatorFixture f = fixture();
+    f.setFor(SqlStdOperatorTable.BITXOR_OPERATOR, VM_EXPAND);
+
+    // Basic XOR between two integer literals
+    f.checkScalar("2 ^ 3", "1", "INTEGER NOT NULL");
+    f.checkScalar("CAST(2 AS INTEGER) ^ CAST(3 AS BIGINT)", "1", "BIGINT NOT NULL");
+    f.checkScalar("-5 ^ 7", "-4", "INTEGER NOT NULL");
+    f.checkScalar("-5 ^ -7", "2", "INTEGER NOT NULL");
+    f.checkScalar("CAST(-5 AS TINYINT) ^ CAST(7 AS TINYINT)", "-4", "TINYINT NOT NULL");
+    f.checkScalar("CAST(-5 AS TINYINT) ^ CAST(-31 AS TINYINT)", "26", "TINYINT NOT NULL");
+    f.checkType("CAST(2 AS TINYINT) ^ CAST(6 AS TINYINT)", "TINYINT NOT NULL");
+    f.checkType("CAST(2 AS SMALLINT) ^ CAST(6 AS SMALLINT)", "SMALLINT NOT NULL");
+    f.checkType("CAST(2 AS BIGINT) ^ CAST(6 AS BIGINT)", "BIGINT NOT NULL");

Review Comment:
   we now support unsigned numbers, can you add one test with one of these?



##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -3226,7 +3226,6 @@ public static ByteString bitNot(ByteString b) {
 
     return new ByteString(result);
   }
-

Review Comment:
   this edit is not particularly useful



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2215806411


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -16294,6 +16299,48 @@ private static void checkLogicalOrFunc(SqlOperatorFixture f) {
     f.checkAgg("logical_or(x)", values4, isNullValue());
   }
 
+  @Test void testBitXorOperatorParserFunc() throws SqlParseException {
+    String sql = "SELECT 5 ^ 3 ";
+    SqlNode sqlNode = SqlParser.create(sql,  SqlParser.Config.DEFAULT).parseStmt();
+
+    assertInstanceOf(SqlSelect.class, sqlNode);
+    SqlSelect select = (SqlSelect) sqlNode;
+
+    SqlNode selectItem = select.getSelectList().get(0);
+    assertInstanceOf(SqlBasicCall.class, selectItem);
+    SqlBasicCall call = (SqlBasicCall) selectItem;
+    assertEquals(SqlStdOperatorTable.BITXOR_OPERATOR, call.getOperator());
+    assertEquals(2, call.getOperandList().size());
+  }
+
+  @Test void testBitXorOperatorScalarFunc() {
+    final SqlOperatorFixture f = fixture();
+    f.setFor(SqlStdOperatorTable.BITXOR_OPERATOR, VM_EXPAND);
+
+    // Basic XOR between two integer literals
+    f.checkScalar("2 ^ 3", "1", "INTEGER NOT NULL");
+    f.checkScalar("CAST(2 AS INTEGER) ^ CAST(3 AS BIGINT)", "1", "BIGINT NOT NULL");
+    f.checkScalar("-5 ^ 7", "-4", "INTEGER NOT NULL");
+    f.checkScalar("-5 ^ -7", "2", "INTEGER NOT NULL");
+    f.checkScalar("CAST(-5 AS TINYINT) ^ CAST(7 AS TINYINT)", "-4", "TINYINT NOT NULL");
+    f.checkScalar("CAST(-5 AS TINYINT) ^ CAST(-31 AS TINYINT)", "26", "TINYINT NOT NULL");
+    f.checkType("CAST(2 AS TINYINT) ^ CAST(6 AS TINYINT)", "TINYINT NOT NULL");
+    f.checkType("CAST(2 AS SMALLINT) ^ CAST(6 AS SMALLINT)", "SMALLINT NOT NULL");
+    f.checkType("CAST(2 AS BIGINT) ^ CAST(6 AS BIGINT)", "BIGINT NOT NULL");

Review Comment:
   Added



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3109274747

   I don't understand what Quidem has to do with carets.
   Maybe I am missing something; can you explain what the problem is with an example?
   I still don't know what is the idempotency you are mentioning. What is the operation that has to be applied twice and produce the same results?


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3111717173

   > Quidem has to do with carets.
   
   You're right — Quidem has nothing to do with carets.
   The issue I mentioned is unrelated to Quidem itself.
   When using ^^ (double caret), I've seen that repeated evaluation or type checking (e.g. inside f.checkScalar) can produce inconsistent results.
   This breaks idempotency in tests, since the same expression might yield different results across passes.
   That's why I avoided using ^^ even though it works syntactically.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3106373467

   > I think that doubling a caret is something much simpler for contributors to do to write tests than to understand the rules about when a single caret works and when a double one is required.
   
   I agree that doubling carets is simple in principle — and I’ve tried that approach. Unfortunately, it still breaks idempotency in some cases, especially when Quidem interprets and rewrites the input/output. That’s why I went for a solution that preserves the original SQL and ensures the tests remain stable across runs.
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4339:
URL: https://github.com/apache/calcite/pull/4339#discussion_r2216536538


##########
core/src/main/java/org/apache/calcite/sql/parser/StringAndPos.java:
##########
@@ -52,8 +53,54 @@ private StringAndPos(String sql, int cursor, @Nullable SqlParserPos pos) {
   }
 
   /**
-   * Looks for one or two carets in a SQL string, and if present, converts
-   * them into a parser position.
+   * Checks if the SQL expression is a simple XOR pattern that can be safely processed.
+   *
+   * <p>This method provides special handling for the BITXOR_OPERATOR (^) in Apache Calcite

Review Comment:
   how bad do the tests look if you require escaping in all these cases?
   that may be preferable 



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "Dwrite (via GitHub)" <gi...@apache.org>.
Dwrite commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3096672414

   > Could you also add a few tests in a quidem file (suffix .iq)? The reason I am asking this is because all the tests you wrote involve only constants, so they will be optimized by the compiler. For quidem tests that read from a table the evaluation path is slightly different.
   
   which file are you refering to ? I could not find the suffix.iq file.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6731] Support bitwise XOR (^) operator in SQL [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4339:
URL: https://github.com/apache/calcite/pull/4339#issuecomment-3134794942

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [5 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4339&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4339&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [66.9% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4339&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4339)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org