[ https://issues.apache.org/jira/browse/IMPALA-7951?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul Rogers reassigned IMPALA-7951: ----------------------------------- Assignee: (was: Paul Rogers) > Rewrites change meaning when converted to SQL > --------------------------------------------- > > Key: IMPALA-7951 > URL: https://issues.apache.org/jira/browse/IMPALA-7951 > Project: IMPALA > Issue Type: Bug > Components: Frontend > Affects Versions: Impala 3.1.0 > Reporter: Paul Rogers > Priority: Minor > > Consider this query: > {code:sql} > SELECT int_col not between 1 and 10 and int_col <> -1 > FROM functional.alltypestiny > {code} > Then, render the query using toSql() after rewrites > {code:sql} > SELECT int_col < 1 OR int_col > 10 AND int_col != -1 > FROM functional.alltypestiny > Notice the meaning has changed. Correct grouping: > {code:sql} > (int_col < 1 OR int_col > 10) AND int_col != -1 > {code} > This means to accept all values {{(-infinity, -2), 0 (1, 10)}}. > Actual grouping based on precedence rules: > {code:sql} > int_col < 1 OR (int_col > 10 AND int_col != -1) > {code} > This means to accept all values {{(-infinity, 0)}}. > The rewrites must insert parens if the rewrite would render a tree that is > incorrect when interpreted using default precedence rules. (That is, if a > parent node has lower precedence than a child node.) > The quick fix is to set the “print sql in parens” flag, but this is less than > idea as it adds parens where they are not required. Better would be to > compute the parens based on precedence at toSql time, but that is out of > scope of this fix. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-all-unsubscr...@impala.apache.org For additional commands, e-mail: issues-all-h...@impala.apache.org