Files
impala/testdata/workloads/functional-query/queries/QueryTest/empty.test
Alex Behm 3111827ae2 IMPALA-1101: Plan sub-trees with no results are implemented by an EmptySetNode.
Before: Constant conjuncts used to be registered in the analyzer together with
non-constant conjuncts. Since constant conjuncts are not bound by any slot or
tuple they were incorrectly placed into whatever plan node called init() first
and then were incorrectly marked as assigned. For handling queries with a
limit 0 we had special code in the BE.

After: Since constant conjuncts do not fit well into the existing slot/tuple
based assignment logic this patch treats them specially as follows. Constant
that do not originate from the ON clause of an outer join are evaluated
directly. Depending on which clause the conjunct came from either the entire
query block is marked as returning an empty set (HAVING clause) or the block
is marked as having an empty select-project-join portion (ON and WHERE clause).
In the latter case, aggregations (if any) must still be performed.
The plan sub-trees that are guaranteed to return an empty result set are
implemented by an EmptySetNode. Constant conjuncts from the ON clause of an
outer are assigned to the node implementing the join.

Similarly, query blocks with a limit 0 are marked as returning an empty result,
and planned as an EmptySetNode.

As a side effect, this patch also fixes:
IMPALA-89: Make our behavior of INSERT OVERWRITE ... LIMIT 0
consistent with Hive's. The target table is left empty after
such an operation.

Change-Id: Ia35679ac0b3a9d94edae7f310efc4d934c1bfb0d
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/3653
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: jenkins
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/3800
2014-08-08 04:35:31 -07:00

94 lines
1.6 KiB
Plaintext

====
---- QUERY
# testtbl is empty
select * from testtbl
---- TYPES
bigint, string, int
---- RESULTS
====
---- QUERY
# month ends at 12
select int_col from alltypessmall where month > 100
---- TYPES
int
---- RESULTS
====
---- QUERY
# Empty partitioned table test
select field from emptytable
---- TYPES
string
---- RESULTS
====
---- QUERY
# Constant conjunct.
select t1.id, t2.id
from functional.alltypestiny t1
left outer join functional.alltypes t2
on t1.id = t2.id
where false
---- TYPES
int, int
---- RESULTS
====
---- QUERY
# Constant conjunct in query block with an aggregation.
select count(int_col), avg(double_col), count(*)
from functional.alltypes
where null
---- TYPES
bigint, double, bigint
---- RESULTS
0,NULL,0
====
---- QUERY
# Constant conjunct in inline view.
select e.id, f.id
from functional.alltypessmall f
inner join
(select t1.id
from functional.alltypestiny t1
left outer join functional.alltypes t2
on t1.id = t2.id
where 1 + 3 > 10) e
on e.id = f.id
---- TYPES
int, int
---- RESULTS
====
---- QUERY
# Limit 0
select t1.id, t2.id
from functional.alltypestiny t1
left outer join functional.alltypes t2
on t1.id = t2.id
limit 0
---- TYPES
int, int
---- RESULTS
====
---- QUERY
# Limit 0 in query block with an aggregation
select count(int_col), avg(double_col), count(*)
from functional.alltypes
limit 0
---- TYPES
bigint, double, bigint
---- RESULTS
====
---- QUERY
# Limit 0 in inline view
select e.id, f.id
from functional.alltypessmall f
inner join
(select t1.id
from functional.alltypestiny t1
left outer join functional.alltypes t2
on t1.id = t2.id
limit 0) e
on e.id = f.id
---- TYPES
int, int
---- RESULTS
====