[ 
https://issues.apache.org/jira/browse/CALCITE-6475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17866886#comment-17866886
 ] 

xiong duan commented on CALCITE-6475:
-------------------------------------

[~asolimando] Hi, we use `inSubQueryThreshold` to control the IN-list to be 
converted join against a VALUES or to OR predicate.

For example:
{code:java}
!use foodmart
!set outputformat mysql
!set insubquerythreshold 0

select * from "product" where ("product_id") in (12, null);

EnumerableHashJoin(condition=[=($1, $15)], joinType=[semi])
  EnumerableTableScan(table=[[foodmart2, product]])
  EnumerableValues(tuples=[[{ 12 }, { null }]])
!plan

!set insubquerythreshold 3

select * from "product" where ("product_id") in (12, null);

EnumerableCalc(expr#0..14=[{inputs}], expr#15=[12], expr#16=[=($t1, $t15)], 
proj#0..14=[{exprs}], $condition=[$t16])
  EnumerableTableScan(table=[[foodmart2, product]])
!plan

# End dummy.iq {code}
I hope it is helpful.

> RelToSql converter fails when IN-list that the values include NULL is 
> converted to Values
> -----------------------------------------------------------------------------------------
>
>                 Key: CALCITE-6475
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6475
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: xiong duan
>            Priority: Major
>
> The SQL
> {code:java}
> select * from "product" where ("product_id") in (12, null){code}
> When we convert the IN-list to OR condition, it can run successfully. But 
> when we convert it to VALUES, it will throw NPE:
> {code:java}
> java.lang.NullPointerException
>     at 
> org.apache.calcite.rel.rel2sql.SqlImplementor.toSql(SqlImplementor.java:1468)
>     at 
> org.apache.calcite.rel.rel2sql.SqlImplementor.toSql(SqlImplementor.java:1416)
>     at 
> org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:702)
>     at 
> org.apache.calcite.rel.rel2sql.RelToSqlConverter.lambda$exprList$17(RelToSqlConverter.java:1158){code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to