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

Applying De Morgan's laws can invalidate query statement

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Frontend
    • None

    Description

      Given the following query:

      SELECT *
      FROM functional.alltypes
      WHERE NOT (id < 10 AND
                 (int_col IN (SELECT int_col
                              FROM functional.alltypestiny)) AND
                 (string_col = (SELECT max(string_col)
                                FROM functional.alltypestiny)))

      We get the following error message:

      ERROR: AnalysisException: Subqueries in OR predicates are not supported: id >= 10 OR int_col NOT IN (SELECT int_col FROM functional.alltypestiny) OR string_col != (SELECT max(string_col) FROM functional.alltypestiny)

      Which is strange, because we only have AND predicates in our statement.

      When Impala rewrites the query it applies De Morgan's laws, so it pushes the NOT predicate into the conditions and turns the AND predicates to ORs. And that's invalidates our query statement, because subqueries in OR predicates are not allowed.

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              boroknagyz Zoltán Borók-Nagy
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: