Files
impala/testdata/workloads/functional-query/queries/QueryTest/hdfs-caching.test
Martin Grund fdafbc5709 IMPALA-1645 and IMPALA-1632: Verify Cache Directives
When a table is loaded in the catalog, we will now perform a check to
verify that the cache directive ID and cache replication factor is still
valid and the data is current.

If the cache directive does no longer exist, we issue a error message
and mark the table / partition as uncached. Furthermore, the replication
factor is updated with the information from the actual cache directive.

In the case of insert statement there is a special situation as the
catalog update is happening synchronously and will try to access the
cache directive information that might be stale. Thus in this insert
path, we catch the possible not found exception and reset the caching
information.

Change-Id: I882041ce5395b8a3d17e9fc2750053393340df65
Reviewed-on: http://gerrit.cloudera.org:8080/40
Reviewed-by: Martin Grund <mgrund@cloudera.com>
Tested-by: Internal Jenkins
2015-02-11 03:35:46 +00:00

305 lines
9.0 KiB
Plaintext

====
---- QUERY
use cachedb
====
---- QUERY
create table cached_tbl_nopart (i int) cached in 'testPool'
====
---- QUERY
insert into cached_tbl_nopart select 1
---- RESULTS
: 1
====
---- QUERY
select * from cached_tbl_nopart
---- RESULTS
1
---- TYPES
INT
====
---- QUERY
# Unpartitioned table shows correct caching
show table stats cached_tbl_nopart
---- RESULTS
-1,1,'2B',regex:.+B,'1','TEXT','false'
---- TYPES
BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# Unpartitioned table is no longer cached
alter table cached_tbl_nopart set uncached
====
---- QUERY
show table stats cached_tbl_nopart
---- RESULTS
-1,1,'2B','NOT CACHED','NOT CACHED','TEXT','false'
---- TYPES
BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
drop table if exists cached_tbl_part
====
---- QUERY
create table cached_tbl_part (i int) partitioned by (j int) cached in 'testPool' with replication = 9
====
---- QUERY
# new partition should inherit the cached property
alter table cached_tbl_part add partition (j=0)
====
---- QUERY
# should be able to override the inherited cached property
alter table cached_tbl_part add partition (j=1) uncached
====
---- QUERY
alter table cached_tbl_part add partition (j=2) cached in 'testPool'
====
---- QUERY
show partitions cached_tbl_part
---- RESULTS
'0',-1,0,'0B',regex:.+B,'9','TEXT','false'
'1',-1,0,'0B','NOT CACHED','NOT CACHED','TEXT','false'
'2',-1,0,'0B',regex:.+B,'9','TEXT','false'
'Total',-1,0,'0B',regex:.+B,'','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
drop table if exists cached_tbl_part
====
---- QUERY
create table cached_tbl_part (i int) partitioned by (j int) cached in 'testPool'
====
---- QUERY
# new partition should inherit the cached property
alter table cached_tbl_part add partition (j=0)
====
---- QUERY
# should be able to override the inherited cached property
alter table cached_tbl_part add partition (j=1) uncached
====
---- QUERY
alter table cached_tbl_part add partition (j=2) cached in 'testPool'
====
---- QUERY
show partitions cached_tbl_part
---- RESULTS
'0',-1,0,'0B',regex:.+B,'1','TEXT','false'
'1',-1,0,'0B','NOT CACHED','NOT CACHED','TEXT','false'
'2',-1,0,'0B',regex:.+B,'1','TEXT','false'
'Total',-1,0,'0B',regex:.+B,'','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# uncache one of the partitions
alter table cached_tbl_part partition (j=2) set uncached
====
---- QUERY
show partitions cached_tbl_part
---- RESULTS
'0',-1,0,'0B',regex:.+B,'1','TEXT','false'
'1',-1,0,'0B','NOT CACHED','NOT CACHED','TEXT','false'
'2',-1,0,'0B','NOT CACHED','NOT CACHED','TEXT','false'
'Total',-1,0,'0B',regex:.+B,'','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# Can uncache the same partition twice without an error.
alter table cached_tbl_part partition (j=2) set uncached
====
---- QUERY
show partitions cached_tbl_part
---- RESULTS
'0',-1,0,'0B',regex:.+B,'1','TEXT','false'
'1',-1,0,'0B','NOT CACHED','NOT CACHED','TEXT','false'
'2',-1,0,'0B','NOT CACHED','NOT CACHED','TEXT','false'
'Total',-1,0,'0B',regex:.+B,'','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# mark an uncached partition as cached
alter table cached_tbl_part partition (j=1) set cached in 'testPool'
====
---- QUERY
show partitions cached_tbl_part
---- RESULTS
'0',-1,0,'0B',regex:.+B,'1','TEXT','false'
'1',-1,0,'0B',regex:.+B,'1','TEXT','false'
'2',-1,0,'0B','NOT CACHED','NOT CACHED','TEXT','false'
'Total',-1,0,'0B',regex:.+B,'','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# dynamic partition insert inherits table properties
insert into cached_tbl_part partition(j) values(3, 3), (4, 4);
---- RESULTS
j=3/: 1
j=4/: 1
====
---- QUERY
# Modify partition cache replication
alter table cached_tbl_part partition (j=3) set cached in 'testPool' with replication = 4
====
---- QUERY
show partitions cached_tbl_part
---- RESULTS
'0',-1,0,'0B',regex:.+B,'1','TEXT','false'
'1',-1,0,'0B',regex:.+B,'1','TEXT','false'
'2',-1,0,'0B','NOT CACHED','NOT CACHED','TEXT','false'
'3',-1,1,'2B',regex:.+B,'4','TEXT','false'
'4',-1,1,'2B',regex:.+B,'1','TEXT','false'
'Total',-1,2,'4B',regex:.+B,'','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# Set uncached clears all cache requests
alter table cached_tbl_part set uncached
---- RESULTS
====
---- QUERY
show partitions cached_tbl_part
---- RESULTS
'0',-1,0,'0B','NOT CACHED','NOT CACHED','TEXT','false'
'1',-1,0,'0B','NOT CACHED','NOT CACHED','TEXT','false'
'2',-1,0,'0B','NOT CACHED','NOT CACHED','TEXT','false'
'3',-1,1,'2B','NOT CACHED','NOT CACHED','TEXT','false'
'4',-1,1,'2B','NOT CACHED','NOT CACHED','TEXT','false'
'Total',-1,2,'4B',regex:.+B,'','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# Can call set uncached multiple times on the same partitioned table
alter table cached_tbl_part set uncached
---- RESULTS
====
---- QUERY
# Set cached caches all partitions
alter table cached_tbl_part set cached in 'testPool'
---- RESULTS
====
---- QUERY
show partitions cached_tbl_part
---- RESULTS
'0',-1,0,'0B',regex:.+B,'1','TEXT','false'
'1',-1,0,'0B',regex:.+B,'1','TEXT','false'
'2',-1,0,'0B',regex:.+B,'1','TEXT','false'
'3',-1,1,'2B',regex:.+B,'1','TEXT','false'
'4',-1,1,'2B',regex:.+B,'1','TEXT','false'
'Total',-1,2,'4B',regex:.+B,'','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# Can call set cached multiple times on the same partitioned table.
alter table cached_tbl_part set cached in 'testPool'
---- RESULTS
====
---- QUERY
show partitions cached_tbl_part
---- RESULTS
'0',-1,0,'0B',regex:.+B,'1','TEXT','false'
'1',-1,0,'0B',regex:.+B,'1','TEXT','false'
'2',-1,0,'0B',regex:.+B,'1','TEXT','false'
'3',-1,1,'2B',regex:.+B,'1','TEXT','false'
'4',-1,1,'2B',regex:.+B,'1','TEXT','false'
'Total',-1,2,'4B',regex:.+B,'','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# Modify partition cache replication in preparation for table level alteration
alter table cached_tbl_part partition (j=3) set cached in 'testPool' with replication = 4
====
---- QUERY
# Uncache a partition in preparation for table level alteration
alter table cached_tbl_part partition (j=1) set uncached
====
---- QUERY
show partitions cached_tbl_part
---- RESULTS
'0',-1,0,'0B',regex:.+B,'1','TEXT','false'
'1',-1,0,'0B','NOT CACHED','NOT CACHED','TEXT','false'
'2',-1,0,'0B',regex:.+B,'1','TEXT','false'
'3',-1,1,'2B',regex:.+B,'4','TEXT','false'
'4',-1,1,'2B',regex:.+B,'1','TEXT','false'
'Total',-1,2,'4B',regex:.+B,'','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# Set replication factor for all partitions regardless of their current state
alter table cached_tbl_part set cached in 'testPool' with replication = 8
---- RESULTS
====
---- QUERY
show partitions cached_tbl_part
---- RESULTS
'0',-1,0,'0B',regex:.+B,'8','TEXT','false'
'1',-1,0,'0B',regex:.+B,'8','TEXT','false'
'2',-1,0,'0B',regex:.+B,'8','TEXT','false'
'3',-1,1,'2B',regex:.+B,'8','TEXT','false'
'4',-1,1,'2B',regex:.+B,'8','TEXT','false'
'Total',-1,2,'4B',regex:.+B,'','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# Add partition with different replication
alter table cached_tbl_part add partition(j=5) cached in 'testPool' with replication = 3
---- RESULTS
====
---- QUERY
show partitions cached_tbl_part
---- RESULTS
'0',-1,0,'0B',regex:.+B,'8','TEXT','false'
'1',-1,0,'0B',regex:.+B,'8','TEXT','false'
'2',-1,0,'0B',regex:.+B,'8','TEXT','false'
'3',-1,1,'2B',regex:.+B,'8','TEXT','false'
'4',-1,1,'2B',regex:.+B,'8','TEXT','false'
'5',-1,0,'0B',regex:.+B,'3','TEXT','false'
'Total',-1,2,'4B',regex:.+B,'','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# Change replication for a partition
alter table cached_tbl_part partition(j=2) set cached in 'testPool' with replication = 3
---- RESULTS
====
---- QUERY
show partitions cached_tbl_part
---- RESULTS
'0',-1,0,'0B',regex:.+B,'8','TEXT','false'
'1',-1,0,'0B',regex:.+B,'8','TEXT','false'
'2',-1,0,'0B',regex:.+B,'3','TEXT','false'
'3',-1,1,'2B',regex:.+B,'8','TEXT','false'
'4',-1,1,'2B',regex:.+B,'8','TEXT','false'
'5',-1,0,'0B',regex:.+B,'3','TEXT','false'
'Total',-1,2,'4B',regex:.+B,'','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# Add partition with inherited replication from table
alter table cached_tbl_part add partition(j=6) cached in 'testPool'
---- RESULTS
====
---- QUERY
show partitions cached_tbl_part
---- RESULTS
'0',-1,0,'0B',regex:.+B,'8','TEXT','false'
'1',-1,0,'0B',regex:.+B,'8','TEXT','false'
'2',-1,0,'0B',regex:.+B,'3','TEXT','false'
'3',-1,1,'2B',regex:.+B,'8','TEXT','false'
'4',-1,1,'2B',regex:.+B,'8','TEXT','false'
'5',-1,0,'0B',regex:.+B,'3','TEXT','false'
'6',-1,0,'0B',regex:.+B,'8','TEXT','false'
'Total',-1,2,'4B',regex:.+B,'','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING
====