Jesus Camacho Rodriguez created CALCITE-4716: ------------------------------------------------
Summary: ClassCastException converting SARG in RelNode to SQL Key: CALCITE-4716 URL: https://issues.apache.org/jira/browse/CALCITE-4716 Project: Calcite Issue Type: Bug Components: core Reporter: Jesus Camacho Rodriguez Assignee: Jesus Camacho Rodriguez The stacktrace is the following: {noformat} class org.apache.calcite.rex.RexLocalRef cannot be cast to class org.apache.calcite.rex.RexLiteral (org.apache.calcite.rex.RexLocalRef and org.apache.calcite.rex.RexLiteral are in unnamed module of loader 'app') java.lang.ClassCastException: class org.apache.calcite.rex.RexLocalRef cannot be cast to class org.apache.calcite.rex.RexLiteral (org.apache.calcite.rex.RexLocalRef and org.apache.calcite.rex.RexLiteral are in unnamed module of loader 'app') at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:695) at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:597) ... {noformat} The relevant expressions in the Calc operator are the following: {code} ...expr#5=[Sarg[(10..11]]], expr#6=[SEARCH($t0, $t5)]... {code} The current code in {{SqlImplementor}} considers the second argument to SEARCH is always a RexLiteral: {code} ... case SEARCH: final RexCall search = (RexCall) rex; literal = (RexLiteral) search.operands.get(1); final Sarg sarg = castNonNull(literal.getValueAs(Sarg.class)); //noinspection unchecked return toSql(program, search.operands.get(0), literal.getType(), sarg); ... {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)