Uploaded image for project: 'Kylin'
  1. Kylin
  2. KYLIN-1039

Filter like (A or false) yields wrong result

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: v1.0
    • Fix Version/s: v1.2, v1.4.0
    • Component/s: Query Engine
    • Labels:

      Description

      The following query on test dataset produces a result set containing 5 rows.

      select test_cal_dt.week_beg_dt, sum(price) as GMV
       from test_kylin_fact 
       inner JOIN edw.test_cal_dt as test_cal_dt  ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt 
       where test_cal_dt.week_beg_dt between DATE '2013-09-01' and DATE '2013-10-01' and lstg_format_name='FP-GTC'
       group by test_cal_dt.week_beg_dt
      

      However, if I change the where condition to the following, Kylin produces empty result. This is wrong because `A or false` is just `A`, the result should be the same as above qeury.

       where test_cal_dt.week_beg_dt between DATE '2013-09-01' and DATE '2013-10-01' and (lstg_format_name='FP-GTC' or 'a' = 'b')
      

      I have tried to add a constant folding rule `ReduceExpressionsRule.FILTER_INSTANCE` from calcite, expecting planner to reduce the second query to the first one. But it didn't work. Seems the rule has bug in itself, see https://issues.apache.org/jira/browse/DRILL-2218.

      As as result, we need more investigating to see why it goes wrong and fix the problem.

      BTW, the second query may seems rediculous at first glance. But in fact this kind of query is generated by one of our reporting front-end.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                gaodayue Dayue Gao
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: