Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-5683

Incorrect query result when query uses NOT(IS NOT NULL) expression

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.16.0
    • None
    • None

    Description

      The following repo was modified from a testcase provided by Arjun Rajan(arajan@mapr.com).

      1. Prepare dataset with null.

      create table dfs.tmp.t1 as 
        select r_regionkey, r_name, case when mod(r_regionkey, 3) > 0 then mod(r_regionkey, 3) else null end as flag 
        from cp.`tpch/region.parquet`;
      
      select * from dfs.tmp.t1;
      +--------------+--------------+-------+
      | r_regionkey  |    r_name    | flag  |
      +--------------+--------------+-------+
      | 0            | AFRICA       | null  |
      | 1            | AMERICA      | 1     |
      | 2            | ASIA         | 2     |
      | 3            | EUROPE       | null  |
      | 4            | MIDDLE EAST  | 1     |
      +--------------+--------------+-------+
      

      2. Query with NOT(IS NOT NULL) expression in the filter.

      select * from dfs.tmp.t1 where NOT (flag IS NOT NULL);
      
      +--------------+---------+-------+
      | r_regionkey  | r_name  | flag  |
      +--------------+---------+-------+
      | 0            | AFRICA  | null  |
      | 3            | EUROPE  | null  |
      +--------------+---------+-------+
      

      3. Switch run-time code compiler from default to 'JDK', and get wrong result.

      alter system set `exec.java_compiler` = 'JDK';
      
      +-------+------------------------------+
      |  ok   |           summary            |
      +-------+------------------------------+
      | true  | exec.java_compiler updated.  |
      +-------+------------------------------+
      
      select * from dfs.tmp.t1 where NOT (flag IS NOT NULL);
      +--------------+--------------+-------+
      | r_regionkey  |    r_name    | flag  |
      +--------------+--------------+-------+
      | 0            | AFRICA       | null  |
      | 1            | AMERICA      | 1     |
      | 2            | ASIA         | 2     |
      | 3            | EUROPE       | null  |
      | 4            | MIDDLE EAST  | 1     |
      +--------------+--------------+-------+
      

      4. Wrong result could happen too, when NOT(IS NOT NULL) in Project operator.

      select r_regionkey, r_name, NOT(flag IS NOT NULL) as exp1 from dfs.tmp.t1;
      +--------------+--------------+-------+
      | r_regionkey  |    r_name    | exp1  |
      +--------------+--------------+-------+
      | 0            | AFRICA       | true  |
      | 1            | AMERICA      | true  |
      | 2            | ASIA         | true  |
      | 3            | EUROPE       | true  |
      | 4            | MIDDLE EAST  | true  |
      +--------------+--------------+-------+
      

      Attachments

        Issue Links

          Activity

            People

              volodymyr Vova Vysotskyi
              jni Jinfeng Ni
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: