Skip to content

Commit

Permalink
[CALCITE-5865] ClassCastException with FLOOR and CEIL on conformances…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
gianm committed Jul 20, 2023
1 parent 3ab8003 commit 94b78e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/src/main/codegen/templates/Parser.jj
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2701,11 +2701,10 @@ public static SqlOperator like(boolean negated, boolean caseSensitive) {

/** 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;
}
}
Expand Down

0 comments on commit 94b78e9

Please sign in to comment.