Thanks for the inputs. I have filed https://issues.apache.org/jira/browse/CALCITE-4048 with the summary from this email thread.
Thanks, Maytas Thanks Maytas ~ > > You requests are reasonable, i think line [1] can be promoted, we can move > the null literals > comparison to the last of composition predicates (OR/AND) instead of > forbidden all the IN > to OR(AND) conversion if the IN value list contains nulls. > Can you log an issue there so the one that are interested in it would > contribute ~ > > Thanks again ~ > > [1] > https://github.com/apache/calcite/blob/feae6fbc328e3a7c87693951d1623f8b47ccea59/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java#L1102 > > Best, > Danny Chan > 在 2020年6月6日 +0800 AM5:38,Rui Wang <[email protected]>,写道: > > I see. I was confused on when dim is null, how will null be equal to null. > > Did a quick check and Calcite seems to return Unknown for both "null = > > null" and "null = false". I am not sure it means for OR, Unknown is > > treated as false thus your example can be simplified. > > > > > > -Rui > > > > On Fri, Jun 5, 2020 at 2:27 PM Rui Wang <[email protected]> wrote: > > > > > Per the commit history I think you can find something in > > > https://issues.apache.org/jira/browse/CALCITE-373. > > > > > > Meanwhile, "dim='a' OR dim=null" can be simplified to dim='a'? > > > > > > > > > > > > -Rui > > > > > > On Fri, Jun 5, 2020 at 2:13 PM Maytas Monsereenusorn <[email protected]> > > > wrote: > > > > > > > Hi Calcite, > > > > > > > > I am wondering why we convert a value list with NULL into an inline > > > > table. > > > > The code is in SqlToRelConverter, where we call > > > > !containsNullLiteral(valueList). For example, if I have a SQL select * > > > > from > > > > druid.foo where dim in ('a', null) then why do we not convert this to > > > > dim='a' OR dim=null. > > > > Furthermore, this then can be simply to just dim='a' since dim=null is > > > > always null. > > > > > > > > The plan I got after converting SqlNode to RelNode: > > > > LogicalProject(__time=[$0], cnt=[$1], dim1=[$2], dim2=[$3], dim3=[$4], > > > > m1=[$5], m2=[$6], unique_dim1=[$7]) > > > > LogicalJoin(condition=[=($3, $8)], joinType=[inner]) > > > > LogicalTableScan(table=[[druid, foo]]) > > > > LogicalAggregate(group=[{0}]) > > > > LogicalValues(tuples=[[{ 'a' }, { null }]]) > > > > however, i expect: > > > > LogicalProject(__time=[$0], cnt=[$1], dim1=[$2], dim2=[$3], dim3=[$4], > > > > m1=[$5], m2=[$6], unique_dim1=[$7]) > > > > LogicalFilter(condition=[OR(=($3, 'a'), =($3, null))]) > > > > LogicalTableScan(table=[[druid, foo]]) > > > > > > > > or something like: > > > > LogicalProject(__time=[$0], cnt=[$1], dim1=[$2], dim2=[$3], dim3=[$4], > > > > m1=[$5], m2=[$6], unique_dim1=[$7]) > > > > LogicalFilter(condition=[=($3, 'a')]) > > > > LogicalTableScan(table=[[druid, foo]]) > > > > > > > > Thanks! > > > > -Maytas > > > > > > > > >
