Details
-
Bug
-
Status: Resolved
-
Blocker
-
Resolution: Fixed
-
Impala 2.5.0
-
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 )