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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • Impala 2.5.0
    • Impala 2.7.0, Impala 2.6.2
    • Frontend
    • 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

        1. image-2016-06-05-20-05-09-133.png
          55 kB
          fishing
        2. screenshot-1.png
          96 kB
          fishing

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: