You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "duan xiong (Jira)" <ji...@apache.org> on 2021/09/01 01:06:00 UTC

[jira] [Commented] (CALCITE-4758) When ALL sub-query contains 3-valued logic, Calcite returns wrong result

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

duan xiong commented on CALCITE-4758:
-------------------------------------

Hi.[~julianhyde] I find two related issues that need to confirm:

1)When convert SQL to RelNode, set the expand is true, Then a lot of unit tests are wrong. So this is a bug or recommendation to set expand is false?

2)When we need to convert IN sub-query to OR condition, This handle needs value list can't include NullLiteral, I want to know why. I think whether valueList includes Null Literal or not, It all can be converted.
{code:java}
if (!containsNullLiteral(valueList)
    && valueList.size() < config.getInSubQueryThreshold()) {
  // We're under the threshold, so convert to OR.
  subQuery.expr =
      convertInToOr(
          bb,
          leftKeys,
          valueList,
          (SqlInOperator) call.getOperator());
  return;
}{code}
 

The CALCITE-4742 is about to implement "<>some" subquery in SubQueryRemoveRule.

This issue is caused by SqlToRelConverter substituteSubQuery can't handle correctly when the subquery is an instance of SqlNodeList. So It is different but maybe related.

> When ALL sub-query contains  3-valued logic, Calcite returns wrong result
> -------------------------------------------------------------------------
>
>                 Key: CALCITE-4758
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4758
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.27.0
>            Reporter: duan xiong
>            Assignee: duan xiong
>            Priority: Major
>
> In 3-valued logic, as we know:
> {code:java}
> unknow and false => false
> {code}
> So the SQL:
> {code:java}
> select 1 = all(null, 2) should return false but is null.
> {code}
> {code:java}
> select 1 = all(null, 2, 1) should return false but is true.
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)