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

Preconditions check in SortNode when planning query that has union operands with order by + limit

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: Impala 2.5.0
    • Fix Version/s: Impala 2.7.0, Impala 2.6.2
    • Component/s: Frontend
    • Labels:
      None

      Description

      Predicates from enclosing query blocks are not properly pushed into union operands that have an order by + limit.
      This problem manifests itself as a failed Preconditions check because the SortNode incorrectly picks up such predicates.

      Repro:

      select * from
        ((select * from functional.alltypes order by id limit 10)
          union all
         (select * from functional.alltypes order by id limit 10)) v
      where v.id < 10
      ERROR: IllegalStateException: null
      

      The predicate should be placed into a SelectNode in the union branche(s) that have an order by + limit.

      Original JIRA description
      SELECT xxxxxx.brand_id, cn_name FROM ( (SELECT brand_id FROM (SELECT brand_id, sum(pv) AS g FROM flow_minute_pv GROUP BY brand_id) xx ORDER BY g DESC LIMIT 15) UNION (SELECT brand_id FROM (SELECT brand_id, sum(CASE WHEN gmv IS NULL THEN 0 ELSE gmv END) AS g FROM flow_minute_sku_gmv GROUP BY brand_id) xx ORDER BY g DESC LIMIT 15)) xxxxxx LEFT JOIN brands b ON xxxxxx.brand_id = b.brand_id WHERE xxxxxx.brand_id > 0

      ERROR: IllegalStateException: null in SortNode.java 93 行


      with out left join query is normal
      like this :

      (SELECT brand_id
      FROM
      (SELECT brand_id,
      sum(pv) AS g
      FROM flow_minute_pv
      GROUP BY brand_id) xx
      ORDER BY g DESC LIMIT 15 )
      UNION
      ( SELECT brand_id
      FROM
      (SELECT brand_id,
      sum(CASE WHEN gmv IS NULL THEN 0 ELSE gmv END) AS g
      FROM flow_minute_sku_gmv
      GROUP BY brand_id) xx
      ORDER BY g DESC LIMIT 15 )

        Attachments

          Activity

            People

            • Assignee:
              alex.behm Alexander Behm
              Reporter:
              fish0515_impala_49b1 fishing
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: