This is an automated email from the ASF dual-hosted git repository.

gian pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new 94b78e9884 [CALCITE-5865] ClassCastException with FLOOR and CEIL on 
conformances that are not builtin
94b78e9884 is described below

commit 94b78e9884bb3492527e67b25afa9f28c45ba4a2
Author: Gian Merlino <[email protected]>
AuthorDate: Wed Jul 19 16:20:21 2023 -0700

    [CALCITE-5865] ClassCastException with FLOOR and CEIL on conformances that 
are not builtin
    
    CALCITE-5747 introduced some BigQuery-specific logic for FLOOR and CEIL 
that is keyed off
    the conformance being SqlConformanceEnum.BIG_QUERY. However, it was 
implemented in such a
    way that implementations of SqlConformance that are not SqlConformanceEnum 
would throw
    ClassCastException.
---
 core/src/main/codegen/templates/Parser.jj                          | 2 +-
 .../main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java  | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/core/src/main/codegen/templates/Parser.jj 
b/core/src/main/codegen/templates/Parser.jj
index 822f6a407b..1ea1cebcf1 100644
--- a/core/src/main/codegen/templates/Parser.jj
+++ b/core/src/main/codegen/templates/Parser.jj
@@ -7364,7 +7364,7 @@ SqlNode StandardFloorCeilOptions(Span s, boolean 
floorFlag) :
         }
     )?
     <RPAREN> {
-        SqlOperator op = SqlStdOperatorTable.floorCeil(floorFlag, 
(SqlConformanceEnum) this.conformance);
+        SqlOperator op = SqlStdOperatorTable.floorCeil(floorFlag, 
this.conformance);
         function =  op.createCall(s.end(this), args);
     }
     (
diff --git 
a/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java 
b/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
index c4c8afd3a8..86a7cb0a0a 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
@@ -2701,11 +2701,10 @@ public class SqlStdOperatorTable extends 
ReflectiveSqlOperatorTable {
 
   /** Returns the operator for {@code FLOOR} and {@code CEIL} with given floor 
flag
    * and library. */
-  public static SqlOperator floorCeil(boolean floor, SqlConformanceEnum 
conformance) {
-    switch (conformance) {
-    case BIG_QUERY:
+  public static SqlOperator floorCeil(boolean floor, SqlConformance 
conformance) {
+    if (SqlConformanceEnum.BIG_QUERY.equals(conformance)) {
       return floor ? SqlLibraryOperators.FLOOR_BIG_QUERY : 
SqlLibraryOperators.CEIL_BIG_QUERY;
-    default:
+    } else {
       return floor ? SqlStdOperatorTable.FLOOR : SqlStdOperatorTable.CEIL;
     }
   }

Reply via email to