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

Implicit cast does not propagate NDV

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • Impala 3.1.0
    • None
    • Frontend
    • None
    • ghx-label-1

    Description

      See the scenario in IMPALA-7949 in which we have the following SELECT list expression:

      cast(0 as double) = id
      

      Analysis of this expression inserts an implicit cast to force id to the same DOUBLE type as the constant:

      CAST(0 AS DOUBLE) = CAST(id AS DOUBLE)
      

      The code to do this is in the CastExpr(Type targetType, Expr e) constructor. This constructor attempts to analyze the new cast node, but does so incorrectly. (The code is a copy of the analysis code rather than a call to it.) The code calls computeNumDistinctValues() which determines that the cast is not a constant, and sets the NDV to -1.

      The correct answer is to propagate NDV up from the child element. Since NDV of id is 7300, the NDV of the cast should also be 7300. An even better answer is to use the existing analysis code to do the analysis, rather than making a copy.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: