[ https://issues.apache.org/jira/browse/CALCITE-2611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16641976#comment-16641976 ]
Zoltan Haindrich commented on CALCITE-2611: ------------------------------------------- reason behind this issue is that the OptimizeShuttle encounters an expression of {{Boolean.FALSE == null}} ; and it rewrites it into !null which is will prevent the compilation of the resulting source file. https://github.com/apache/calcite/blob/6b3844c0634792263a5073b8ea93565fb3415f41/linq4j/src/main/java/org/apache/calcite/linq4j/tree/OptimizeShuttle.java#L244 > Code generation fails if one side of an or contains unknown > ----------------------------------------------------------- > > Key: CALCITE-2611 > URL: https://issues.apache.org/jira/browse/CALCITE-2611 > Project: Calcite > Issue Type: Bug > Reporter: Zoltan Haindrich > Assignee: Julian Hyde > Priority: Major > > This is rather strange...it needs also an and below which contains the > unknown. > Running the following query: > {code} > !connect jdbc:calcite:model=target/test-classes/model.json admin admin > select (EMPID = 3 and unknown) or ( EMPID = 3) from emps; > {code} > results in a compilation exception; > the main problem is that there is an interesting field: > {code} > static final Object $L4J$C$_null = !null; > {code} > full exception: > {code} > 0: jdbc:calcite:model=target/test-classes/mod> select (cast(EMPID as integer) > = 3 and unknown) or not ( cast(EMPID as integer) = 3) from emps; > Error: Error while executing SQL "select (cast(EMPID as integer) = 3 and > unknown) or not ( cast(EMPID as integer) = 3) from emps": Error while > compiling generated Java code: > org.apache.calcite.DataContext root; > public org.apache.calcite.linq4j.Enumerable bind(final > org.apache.calcite.DataContext root0) { > root = root0; > final org.apache.calcite.rel.RelNode v1stashed = > (org.apache.calcite.rel.RelNode) root.get("v1stashed"); > final org.apache.calcite.interpreter.Interpreter interpreter = new > org.apache.calcite.interpreter.Interpreter( > root, > v1stashed); > return new org.apache.calcite.linq4j.AbstractEnumerable(){ > public org.apache.calcite.linq4j.Enumerator enumerator() { > return new org.apache.calcite.linq4j.Enumerator(){ > public final org.apache.calcite.linq4j.Enumerator inputEnumerator > = interpreter.enumerator(); > public void reset() { > inputEnumerator.reset(); > } > public boolean moveNext() { > return inputEnumerator.moveNext(); > } > public void close() { > inputEnumerator.close(); > } > public Object current() { > final Integer inp5_ = (Integer) ((Object[]) > inputEnumerator.current())[5]; > return inp5_ != null && inp5_.intValue() != 3 ? Boolean.TRUE : > inp5_ != null || $L4J$C$_null || inp5_ == null ? (Boolean) null : > Boolean.FALSE; > } > static final Object $L4J$C$_null = !null; > }; > } > }; > } > public Class getElementType() { > return java.lang.Boolean.class; > } (state=,code=0) > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)