I have managed to reproduce it, and have a fix. Can you assign the case to me, please?
On Wed, Feb 15, 2023 at 9:22 AM Ruben Q L <[email protected]> wrote: > Hello Max, > > Thanks for reporting this. At first glance it seems a regression, could > you please create a Jira ticket (and link it to CALCITE-5424)? > > Best, > Ruben > > > On Wed, Feb 15, 2023 at 3:27 PM Maksim Zhuravkov <[email protected]> > wrote: > >> Hello, team. >> >> Thank you for all the effort you have put into this project over the >> years. >> >> After updating to calcite 1.33.0, I found that validation of the >> following query fails with a ClassCastException. >> >> Query: SELECT COALESCE(DATE '2021-07-08', DATE '2020-01-01’) >> >> Error: >> >> org.apache.calcite.tools.ValidationException: >> java.lang.ClassCastException: class org.apache.calcite.sql.SqlLiteral >> cannot be cast to class org.apache.calcite.sql.SqlUnknownLiteral >> (org.apache.calcite.sql.SqlLiteral and >> org.apache.calcite.sql.SqlUnknownLiteral are in unnamed module of loader >> 'app') >> >> at org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:226) >> at >> org.apache.calcite.rex.RexSqlStandardConvertletTableTest.convertSqlToRel(RexSqlStandardConvertletTableTest.java:101) >> at >> com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) >> at >> com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) >> at >> com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) >> at >> com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) >> at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54) >> Caused by: java.lang.ClassCastException: class >> org.apache.calcite.sql.SqlLiteral cannot be cast to class >> org.apache.calcite.sql.SqlUnknownLiteral (org.apache.calcite.sql.SqlLiteral >> and org.apache.calcite.sql.SqlUnknownLiteral are in unnamed module of >> loader 'app') >> at >> org.apache.calcite.sql.validate.SqlValidatorImpl.resolveLiteral(SqlValidatorImpl.java:6152) >> at >> org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visit(SqlValidatorImpl.java:6617) >> at >> org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visit(SqlValidatorImpl.java:6590) >> >> When I move a commit pointer prior to the commit that introduces >> SqlUnknownLiteral ([CALCITE-5424] Customize handling of literals based on >> type system), the test cases above passes successfully. >> >> I haven’t given a more thorough look at this error and maybe this behaviour >> was introduced after that commit, but I think this error is most likely a >> bug. >> >> The reproducer (added to RexSqlStandardConvertletTableTest): >> >> @Test void testCoalesceWithUnknownLiteral() { >> final Project project = (Project) convertSqlToRel( >> "SELECT COALESCE(DATE '2021-07-08', DATE '2020-01-01')", false); >> >> final RexNode rex = project.getProjects().get(0); >> final RexToSqlNodeConverter rexToSqlNodeConverter = >> rexToSqlNodeConverter(); >> final SqlNode convertedSql = rexToSqlNodeConverter.convertNode(rex); >> >> assertEquals( >> "CASE WHEN DATE '2021-07-08' IS NOT NULL THEN DATE '2021-07-08' ELSE >> DATE '2020-01-01' END", >> convertedSql.toString()); >> } >> >> >> [CALCITE-5424] Customize handling of literals based on type system - ASF >> JIRA <https://issues.apache.org/jira/browse/CALCITE-5424> >> issues.apache.org <https://issues.apache.org/jira/browse/CALCITE-5424> >> [image: fav-jsw.png] <https://issues.apache.org/jira/browse/CALCITE-5424> >> <https://issues.apache.org/jira/browse/CALCITE-5424> >> >> >> Best regards, >> >> Max Zhuravkov >> >> >> >>
