mirror of
https://github.com/apache/impala.git
synced 2025-12-31 15:00:10 -05:00
This patch fixes a few row key issues: 1. We used to assert that the row key filter must be a string literal. However, it can also be a constant function. We need to eval the expr and then use the result as the start/stop key. 2. Cast(row_key as int) simply failed. This should not be transformed into start/stop key. 3. We used to assert that lower bound < upper bound. This query: select * from tbl where row_key > 'b' and row_key < 'a' would simply ASSERT. We should simply not return any rows. 4. Handle NULL predicate HBase row key can't be null. If either upper/lower bound is null, we simply don't need to return any rows. Change-Id: Ia03590a862888b377bf1f48bcb838b99193fa241 Reviewed-on: http://gerrit.ent.cloudera.com:8080/1180 Reviewed-by: Alan Choi <alan@cloudera.com> Tested-by: jenkins
143 lines
2.3 KiB
Plaintext
143 lines
2.3 KiB
Plaintext
====
|
|
---- QUERY
|
|
# predicate on row key col is applied to scan if row key is mapped as string col
|
|
select count(*)
|
|
from functional_hbase.stringids
|
|
where id = '5'
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1
|
|
====
|
|
---- QUERY
|
|
# predicate on row key col is not applied to scan if row key is mapped as non-string col
|
|
# but the result is still correct
|
|
select count(*)
|
|
from functional_hbase.alltypesagg
|
|
where id = 5
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1
|
|
====
|
|
---- QUERY
|
|
# ids are stored in ascii and ordered lexicographically
|
|
# exclusive upper bound
|
|
select count(*)
|
|
from functional_hbase.stringids
|
|
where id < '5'
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
4445
|
|
====
|
|
---- QUERY
|
|
# inclusive upper bound
|
|
select count(*)
|
|
from functional_hbase.stringids
|
|
where id <= '5'
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
4446
|
|
====
|
|
---- QUERY
|
|
# inclusive lower bound
|
|
select count(*)
|
|
from functional_hbase.stringids
|
|
where id >= '6'
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
4444
|
|
====
|
|
---- QUERY
|
|
# exclusive lower bound
|
|
select count(*)
|
|
from functional_hbase.stringids
|
|
where id > '6'
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
4443
|
|
====
|
|
---- QUERY
|
|
# combinations
|
|
select count(*)
|
|
from functional_hbase.stringids
|
|
where id > concat('', '5')
|
|
and id < concat('6', '')
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1110
|
|
====
|
|
---- QUERY
|
|
select count(*)
|
|
from functional_hbase.stringids
|
|
where id >= '5'
|
|
and id < '6'
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1111
|
|
====
|
|
---- QUERY
|
|
select count(*)
|
|
from functional_hbase.stringids
|
|
where id > '5'
|
|
and id <= '6'
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1111
|
|
====
|
|
---- QUERY
|
|
select count(*)
|
|
from functional_hbase.stringids
|
|
where id >= '5'
|
|
and id <= '6'
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1112
|
|
====
|
|
---- QUERY
|
|
# predicates on non-key cols are evaluated in the executor
|
|
# and non-string comparisons work
|
|
select count(*)
|
|
from functional_hbase.stringids
|
|
where id < '5'
|
|
and smallint_col < 5
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
180
|
|
====
|
|
---- QUERY
|
|
# IMP-1188 - row key lower bound is bigger than upper bound.
|
|
select count(*) from functional_hbase.stringids where id > 'b' and id < 'a'
|
|
---- RESULTS
|
|
0
|
|
---- TYPES
|
|
BIGINT
|
|
====
|
|
---- QUERY
|
|
# IMP-1188 - row key predicate is null.
|
|
select count(*) from functional_hbase.stringids
|
|
where id > cast(cast('sdfs' as int) as string)
|
|
---- RESULTS
|
|
0
|
|
---- TYPES
|
|
BIGINT
|
|
====
|
|
---- QUERY
|
|
# IMP-1188 - cast string row key to int
|
|
select count(*) from functional_hbase.stringids
|
|
where cast(id as int) < 5
|
|
---- RESULTS
|
|
5
|
|
---- TYPES
|
|
BIGINT
|
|
====
|