You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@impala.apache.org by "Paul Rogers (JIRA)" <ji...@apache.org> on 2018/12/10 19:23:00 UTC

[jira] [Created] (IMPALA-7949) BinaryPredicate rewrite results in double cast

Paul Rogers created IMPALA-7949:
-----------------------------------

             Summary: BinaryPredicate rewrite results in double cast
                 Key: IMPALA-7949
                 URL: https://issues.apache.org/jira/browse/IMPALA-7949
             Project: IMPALA
          Issue Type: Bug
          Components: Frontend
    Affects Versions: Impala 3.1.0
            Reporter: Paul Rogers
            Assignee: Paul Rogers


Consider the existing unit test: {{ExprRewriteRulesTest.TestNormalizeBinaryPredicatesRule}}, with this SELECT expression:

{code:sql}
cast(0 as double) = id
{code}

The existing test case simply does a "toSql" on the rewritten expression, suppressing implicit casts, expecting:

{code:sql}
id = CAST(0 AS DOUBLE)
{code}

However, if we examine the AST itself, or render the rewritten expression showing implicit casts, we see we get:

{code:sql}
CAST(id AS DOUBLE) = CAST(CAST(0 AS DOUBLE) AS DOUBLE)
{code}

In this particular case, the double-case it benign as the constant-folding rule, if enabled, will remove the two casts. But, if the value were a column, the double casts would exist in the plan sent to the, resulting in an unnecessary extra step.

The expected behavior is the function argument type propagation would not insert a cast if it is not needed.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)