Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-7755

IS [NOT] DISTINCT FROM rewrite rules don't handle aggregates

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • Impala 3.0
    • None
    • Frontend
    • None
    • ghx-label-9

    Description

      Testing revealed one issue and one limitation of the IS [NOT] DISTINCT FROM optimizations in SimplifyDistinctFromRule.

      The rule can simplify sum(id) <=> sum(id) to false. But, according to IMPALA-5125, the rewrite cannot be applied if it would remove the only aggregate. This is a bug.

      A simplification is missing: id IS DISTINCT FROM NULLid IS NOT NULL.

      Here is a specific test case from FullRewriteTest create as part of IMPALA-7655:

        @Test
        public void TestSimplifyDistinctFromRule() throws ImpalaException {
          verifySelectRewrite("if(sum(int_col) <=> sum(int_col), 1, 2)",
              "CASE WHEN sum(int_col) IS NOT DISTINCT FROM sum(int_col) THEN 1 ELSE 2 END");
        }
      

      The above fails, the re-writer produces "2" because it ignores the "must preserve aggregate" rule.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Paul.Rogers Paul Rogers
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: