[
https://issues.apache.org/jira/browse/IGNITE-14612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17326477#comment-17326477
]
Stanilovsky Evgeny edited comment on IGNITE-14612 at 4/21/21, 12:21 PM:
------------------------------------------------------------------------
[~korlov], [~tledkov-gridgain] guys plz check this fix ?
@ScriptRunnerTestsEnvironment(scriptsRoot = "src/test/sql", regex =
"/filter/test_constant_comparisons.test") tests are ok for now.
was (Author: zstan):
[~korlov], [~tledkov-gridgain] guys plz check this fix ?
> Calcite. SELECT with CASE without boolean expression - fails.
> -------------------------------------------------------------
>
> Key: IGNITE-14612
> URL: https://issues.apache.org/jira/browse/IGNITE-14612
> Project: Ignite
> Issue Type: Bug
> Components: sql
> Reporter: Stanilovsky Evgeny
> Assignee: Stanilovsky Evgeny
> Priority: Major
> Labels: calcite
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> For example such expression - fails.
> {noformat}
> SELECT CASE WHEN 1 THEN 13 ELSE 12 END;{noformat}
> failed with:
> {code:java}
> class org.apache.ignite.IgniteException: Error at:
> test_constant_comparisons.test:91. sql: SELECT CASE WHEN 1 THEN 13 ELSE 12
> END;
> at
> org.apache.ignite.internal.processors.query.calcite.logical.SqlScriptRunner$Query.execute(SqlScriptRunner.java:518)
> at
> org.apache.ignite.internal.processors.query.calcite.logical.SqlScriptRunner.run(SqlScriptRunner.java:93)
> at
> org.apache.ignite.internal.processors.query.calcite.logical.ScriptTestRunner$1.run(ScriptTestRunner.java:214)
> at java.lang.Thread.run(Thread.java:748)
> Caused by: class
> org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to
> plan query.
> at
> org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.prepareQuery(ExecutionServiceImpl.java:541)
> at
> org.apache.ignite.internal.processors.query.calcite.prepare.QueryPlanCacheImpl.queryPlan(QueryPlanCacheImpl.java:84)
> at
> org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.executeQuery(ExecutionServiceImpl.java:398)
> at
> org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor.query(CalciteQueryProcessor.java:246)
> at
> org.apache.ignite.internal.processors.query.calcite.logical.SqlScriptRunner.sql(SqlScriptRunner.java:111)
> at
> org.apache.ignite.internal.processors.query.calcite.logical.SqlScriptRunner.access$600(SqlScriptRunner.java:51)
> at
> org.apache.ignite.internal.processors.query.calcite.logical.SqlScriptRunner$Query.execute(SqlScriptRunner.java:513)
> ... 3 more
> Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1,
> column 8 to line 1, column 38: Expected a boolean type
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> at
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:467)
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:883)
> {code}
> and this work perfectly well:
> {noformat}
> SELECT CASE WHEN 1=1 THEN 13 ELSE 12 END;{noformat}
> a little reserch shows that calcite also fails in non boolean expression,
> root cause in
> SqlCaseOperator#checkOperandTypes and further check :
> {code:java}
> if (!SqlTypeUtil.inBooleanFamily(type){code} if we change this place,
> appropriate test
> {noformat}
> @Test void testCaseWhen2() {
> checkPlanEquals("SELECT CASE WHEN 1=1 THEN 13 ELSE 12 END");
> }{noformat}
> will work fine in calcite but will fail in ignite with janino error:
> {noformat}
> class org.apache.ignite.IgniteException: Line 3, Column 7: Not a boolean
> expression
> at
> org.apache.ignite.internal.processors.query.calcite.util.Commons.compile(Commons.java:299)
> at
> org.apache.ignite.internal.processors.query.calcite.exec.exp.ExpressionFactoryImpl.compile(ExpressionFactoryImpl.java:290)
> at
> org.apache.ignite.internal.processors.query.calcite.exec.exp.ExpressionFactoryImpl.lambda$scalar$4(ExpressionFactoryImpl.java:241)
> at
> java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:324)
> at
> org.apache.ignite.internal.processors.query.calcite.exec.exp.ExpressionFactoryImpl.scalar(ExpressionFactoryImpl.java:241)
> at
> org.apache.ignite.internal.processors.query.calcite.exec.exp.ExpressionFactoryImpl.project(ExpressionFactoryImpl.java:198)
> at
> org.apache.ignite.internal.processors.query.calcite.exec.LogicalRelImplementor.visit(LogicalRelImplementor.java:195)
> at
> org.apache.ignite.internal.processors.query.calcite.exec.LogicalRelImplementor.visit(LogicalRelImplementor.java:102)
> at
> org.apache.ignite.internal.processors.query.calcite.rel.IgniteProject.accept(IgniteProject.java:89)
> at
> org.apache.ignite.internal.processors.query.calcite.exec.LogicalRelImplementor.visit(LogicalRelImplementor.java:615)
> at
> org.apache.ignite.internal.processors.query.calcite.exec.LogicalRelImplementor.go(LogicalRelImplementor.java:630)
> at
> org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.executeQuery(ExecutionServiceImpl.java:752)
> at
> org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.executePlan(ExecutionServiceImpl.java:692)
> at
> org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.executePlans(ExecutionServiceImpl.java:418)
> at
> org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.executeQuery(ExecutionServiceImpl.java:400)
> at
> org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor.query(CalciteQueryProcessor.java:246)
> at
> org.apache.ignite.internal.processors.query.calcite.logical.SqlScriptRunner.sql(SqlScriptRunner.java:111)
> at
> org.apache.ignite.internal.processors.query.calcite.logical.SqlScriptRunner.access$600(SqlScriptRunner.java:51)
> at
> org.apache.ignite.internal.processors.query.calcite.logical.SqlScriptRunner$Query.execute(SqlScriptRunner.java:513)
> at
> org.apache.ignite.internal.processors.query.calcite.logical.SqlScriptRunner.run(SqlScriptRunner.java:93)
> at
> org.apache.ignite.internal.processors.query.calcite.logical.ScriptTestRunner$1.run(ScriptTestRunner.java:214)
> at java.lang.Thread.run(Thread.java:748)
> Caused by: org.codehaus.commons.compiler.CompileException: Line 3, Column 7:
> Not a boolean expression
> at
> org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:12211)
> at
> org.codehaus.janino.UnitCompiler.compileBoolean2(UnitCompiler.java:3994)
> at org.codehaus.janino.UnitCompiler.access$6300(UnitCompiler.java:215)
> at
> org.codehaus.janino.UnitCompiler$14.visitIntegerLiteral(UnitCompiler.java:3965)
> at
> org.codehaus.janino.UnitCompiler$14.visitIntegerLiteral(UnitCompiler.java:3935)
> at org.codehaus.janino.Java$IntegerLiteral.accept(Java.java:5453)
> at
> org.codehaus.janino.UnitCompiler.compileBoolean(UnitCompiler.java:3935)
> at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2464)
> at org.codehaus.janino.UnitCompiler.access$1900(UnitCompiler.java:215)
> at
> org.codehaus.janino.UnitCompiler$6.visitIfStatement(UnitCompiler.java:1495)
> at
> org.codehaus.janino.UnitCompiler$6.visitIfStatement(UnitCompiler.java:1487)
> at org.codehaus.janino.Java$IfStatement.accept(Java.java:2950)
> at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:1487)
> at
> org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1567)
> at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:3388)
> at
> org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:1357)
> at
> org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:1330)
> at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:822)
> at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:432)
> at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:215)
> at
> org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:411)
> at
> org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:406)
> at
> org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1414)
> at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:406)
> at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:378)
> at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:237)
> at
> org.codehaus.janino.SimpleCompiler.compileToClassLoader(SimpleCompiler.java:465)
> at
> org.codehaus.janino.ClassBodyEvaluator.compileToClass(ClassBodyEvaluator.java:313)
> at
> org.codehaus.janino.ClassBodyEvaluator.cook(ClassBodyEvaluator.java:235)
> at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:207)
> at org.codehaus.commons.compiler.Cookable.cook(Cookable.java:50)
> at
> org.codehaus.janino.ClassBodyEvaluator.createInstance(ClassBodyEvaluator.java:347)
> at
> org.apache.ignite.internal.processors.query.calcite.util.Commons.compile(Commons.java:297)
> ... 21 more
> {noformat}
> If we need such a syntax in future will dig it here.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)