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

Wrong expression type for addition with invalid cast

    XMLWordPrintableJSON

Details

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

    Description

      Consider this SQL statement:

      SELECT 1 + CAST('123' AS SMALLINT) FROM alltypestiny
      

      This runs as expected and produces the value of 124 as an INT as expected.

      Now consider this version:

      SELECT 1 + CAST('ABC' AS SMALLINT) FROM alltypestiny
      

      This version analyzes OK. The analyzer detects that the cast is invalid and leaves the AST in its original form. However, the analyzer sets the type of the expression to SMALLINT rather than the proper INT.

      (Impala uses conservative type propagation rules: if either operand of addition is SMALLINT, the result should be INT.)

      Would have expected the analyzer to either:

      • Fail the query when it detected the cast failure, or
      • Leave the AST unchanged and leave the expression type unchanged at INT

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: