Files
impala/testdata/workloads/functional-query/queries/QueryTest/compute-stats-incremental.test
Christopher Channing 9ea5caf0ef IMPALA-2199: Row count not set for empty partition when spec is used with compute incremental stats
This patch resolves an issue where row count is not set to 0 when a partition spec is
used with 'compute incremental stats' on a partition that contains no data. The fix is
to populate the partition 'expected list' in the frontend with the partition spec, the
backend keeps track of which partitions had statistics generated. In the scenario where
no statistics are generated for a partition, the backend will fall back to the
'expected list' to zero out the statistics.

Change-Id: If4aac131dbe44e14a0477afa58e980da9e235d6b
Reviewed-on: http://gerrit.cloudera.org:8080/627
Reviewed-by: Christopher Channing <cchanning@cloudera.com>
Tested-by: Internal Jenkins
2015-08-13 09:38:30 +00:00

510 lines
22 KiB
Plaintext

====
---- QUERY
# test computing stats on a partitioned text table with all types
create table compute_stats_db.alltypes_incremental like functional.alltypes;
insert into compute_stats_db.alltypes_incremental partition(year, month)
select * from functional.alltypes;
====
---- QUERY
compute incremental stats compute_stats_db.alltypes_incremental
---- RESULTS
'Updated 24 partition(s) and 11 column(s).'
---- TYPES
STRING
====
---- QUERY
show table stats compute_stats_db.alltypes_incremental
---- RESULTS
'2009','1',310,1,'24.56KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','2',280,1,'22.27KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','3',310,1,'24.67KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','4',300,1,'24.06KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','5',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','6',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','7',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','8',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','9',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','10',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','11',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','12',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','1',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','2',280,1,'22.54KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','3',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','4',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','5',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','6',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','7',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','8',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','9',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','10',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','11',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','12',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'Total','',7300,24,'586.84KB','0B','','','',''
---- TYPES
STRING, STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
show column stats compute_stats_db.alltypes_incremental
---- LABELS
COLUMN, TYPE, #DISTINCT VALUES, #NULLS, MAX SIZE, AVG SIZE
---- RESULTS
'id','INT',7505,-1,4,4
'bool_col','BOOLEAN',2,-1,1,1
'tinyint_col','TINYINT',10,-1,1,1
'smallint_col','SMALLINT',10,-1,2,2
'int_col','INT',10,-1,4,4
'bigint_col','BIGINT',10,-1,8,8
'float_col','FLOAT',10,-1,4,4
'double_col','DOUBLE',10,-1,8,8
'date_string_col','STRING',736,-1,8,8
'string_col','STRING',10,-1,1,1
'timestamp_col','TIMESTAMP',7554,-1,16,16
'year','INT',2,0,4,4
'month','INT',12,0,4,4
---- TYPES
STRING, STRING, BIGINT, BIGINT, INT, DOUBLE
====
---- QUERY
drop incremental stats compute_stats_db.alltypes_incremental partition(year=2010, month=12)
====
---- QUERY
show table stats compute_stats_db.alltypes_incremental;
---- RESULTS
'2009','1',310,1,'24.56KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','2',280,1,'22.27KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','3',310,1,'24.67KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','4',300,1,'24.06KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','5',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','6',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','7',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','8',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','9',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','10',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','11',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','12',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','1',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','2',280,1,'22.54KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','3',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','4',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','5',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','6',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','7',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','8',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','9',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','10',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','11',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','12',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'Total','',7300,24,'586.84KB','0B','','','',''
---- TYPES
STRING, STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
compute incremental stats compute_stats_db.alltypes_incremental
---- RESULTS
'Updated 1 partition(s) and 11 column(s).'
---- TYPES
STRING
====
---- QUERY
show table stats compute_stats_db.alltypes_incremental;
---- RESULTS
'2009','1',310,1,'24.56KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','2',280,1,'22.27KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','3',310,1,'24.67KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','4',300,1,'24.06KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','5',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','6',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','7',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','8',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','9',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','10',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','11',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','12',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','1',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','2',280,1,'22.54KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','3',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','4',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','5',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','6',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','7',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','8',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','9',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','10',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','11',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','12',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'Total','',7300,24,'586.84KB','0B','','','',''
---- TYPES
STRING, STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
show column stats compute_stats_db.alltypes_incremental
---- LABELS
COLUMN, TYPE, #DISTINCT VALUES, #NULLS, MAX SIZE, AVG SIZE
---- RESULTS
'id','INT',7505,-1,4,4
'bool_col','BOOLEAN',2,-1,1,1
'tinyint_col','TINYINT',10,-1,1,1
'smallint_col','SMALLINT',10,-1,2,2
'int_col','INT',10,-1,4,4
'bigint_col','BIGINT',10,-1,8,8
'float_col','FLOAT',10,-1,4,4
'double_col','DOUBLE',10,-1,8,8
'date_string_col','STRING',736,-1,8,8
'string_col','STRING',10,-1,1,1
'timestamp_col','TIMESTAMP',7554,-1,16,16
'year','INT',2,0,4,4
'month','INT',12,0,4,4
---- TYPES
STRING, STRING, BIGINT, BIGINT, INT, DOUBLE
====
---- QUERY
create table compute_stats_db.incremental_empty_partitioned (i int) partitioned by (j int);
alter table compute_stats_db.incremental_empty_partitioned add partition (j=1);
====
---- QUERY
compute incremental stats compute_stats_db.incremental_empty_partitioned;
---- RESULTS
'Updated 1 partition(s) and 1 column(s).'
---- TYPES
STRING
====
---- QUERY
show table stats compute_stats_db.incremental_empty_partitioned;
---- RESULTS
'1',0,0,'0B','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'Total',0,0,'0B','0B','','','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
drop stats compute_stats_db.incremental_empty_partitioned;
====
---- QUERY
# IMPALA-2199: Test that compute incremental stats with a partition spec on an empty partition populates the row count.
compute incremental stats compute_stats_db.incremental_empty_partitioned partition(j=1);
---- RESULTS
'Updated 1 partition(s) and 1 column(s).'
---- TYPES
STRING
====
---- QUERY
show table stats compute_stats_db.incremental_empty_partitioned;
---- RESULTS
'1',0,0,'0B','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'Total',0,0,'0B','0B','','','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
drop incremental stats compute_stats_db.alltypes_incremental partition(year=2010, month=1);
drop incremental stats compute_stats_db.alltypes_incremental partition(year=2010, month=2);
====
---- QUERY
compute incremental stats compute_stats_db.alltypes_incremental partition(year=2010, month=2);
---- RESULTS
'Updated 1 partition(s) and 11 column(s).'
---- TYPES
STRING
====
---- QUERY
show table stats compute_stats_db.alltypes_incremental;
---- RESULTS
'2009','1',310,1,'24.56KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','2',280,1,'22.27KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','3',310,1,'24.67KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','4',300,1,'24.06KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','5',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','6',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','7',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','8',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','9',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','10',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','11',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2009','12',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','1',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2010','2',280,1,'22.54KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','3',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','4',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','5',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','6',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','7',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','8',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','9',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','10',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','11',300,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2010','12',310,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'Total','',6990,24,'586.84KB','0B','','','',''
---- TYPES
STRING, STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
show column stats compute_stats_db.alltypes_incremental
---- LABELS
COLUMN, TYPE, #DISTINCT VALUES, #NULLS, MAX SIZE, AVG SIZE
---- RESULTS
'id','INT',7171,-1,4,4
'bool_col','BOOLEAN',2,-1,1,1
'tinyint_col','TINYINT',10,-1,1,1
'smallint_col','SMALLINT',10,-1,2,2
'int_col','INT',10,-1,4,4
'bigint_col','BIGINT',10,-1,8,8
'float_col','FLOAT',10,-1,4,4
'double_col','DOUBLE',10,-1,8,8
'date_string_col','STRING',688,-1,8,8
'string_col','STRING',10,-1,1,1
'timestamp_col','TIMESTAMP',7249,-1,16,16
'year','INT',2,0,4,4
'month','INT',12,0,4,4
---- TYPES
STRING, STRING, BIGINT, BIGINT, INT, DOUBLE
====
---- QUERY
# Confirm that dropping stats drops incremental stats as well
drop stats compute_stats_db.alltypes_incremental;
show table stats compute_stats_db.alltypes_incremental;
---- RESULTS
'2009','1',-1,1,'24.56KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2009','2',-1,1,'22.27KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2009','3',-1,1,'24.67KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2009','4',-1,1,'24.06KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2009','5',-1,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2009','6',-1,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2009','7',-1,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2009','8',-1,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2009','9',-1,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2009','10',-1,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2009','11',-1,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2009','12',-1,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2010','1',-1,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2010','2',-1,1,'22.54KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2010','3',-1,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2010','4',-1,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2010','5',-1,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2010','6',-1,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2010','7',-1,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2010','8',-1,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2010','9',-1,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2010','10',-1,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2010','11',-1,1,'24.16KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'2010','12',-1,1,'24.97KB','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
'Total','',-1,24,'586.84KB','0B','','','',''
---- TYPES
STRING, STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# Test that many partition keys work correctly
create table compute_stats_db.incremental_many_part_keys(col int)
partitioned by (p1 int, p2 int, p3 int, p4 int, p5 int, p6 int);
insert into compute_stats_db.incremental_many_part_keys
partition(p1=1, p2=2, p3=3, p4=4, p5=5, p6=6) values(1);
====
---- QUERY
compute incremental stats compute_stats_db.incremental_many_part_keys;
show table stats compute_stats_db.incremental_many_part_keys;
---- RESULTS
'1','2','3','4','5','6',1,1,'2B','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'Total','','','','','',1,1,'2B','0B','','','',''
---- TYPES
STRING, STRING, STRING, STRING, STRING, STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
create table compute_stats_db.incremental_null_part_key(col int) partitioned by (p int);
insert into compute_stats_db.incremental_null_part_key partition(p) values(1,NULL), (1,2);
compute incremental stats compute_stats_db.incremental_null_part_key partition(p=2);
====
---- QUERY
compute incremental stats compute_stats_db.incremental_null_part_key partition(p=NULL);
show table stats compute_stats_db.incremental_null_part_key;
---- RESULTS
'NULL',1,1,'2B','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2',1,1,'2B','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'Total',2,2,'4B','0B','','','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# Check that incremental stats queries handle partitions with keyword names
create table compute_stats_db.incremental_keyword_part_key(col int) partitioned by
(`date` int);
insert into compute_stats_db.incremental_keyword_part_key partition(`date`=1) values(2);
compute incremental stats compute_stats_db.incremental_keyword_part_key
partition(`date`=1);
show table stats compute_stats_db.incremental_keyword_part_key;
---- RESULTS
'1',1,1,'2B','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'Total',1,1,'2B','0B','','','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
drop stats compute_stats_db.incremental_keyword_part_key;
compute incremental stats compute_stats_db.incremental_keyword_part_key;
show table stats compute_stats_db.incremental_keyword_part_key;
---- RESULTS
'1',1,1,'2B','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'Total',1,1,'2B','0B','','','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
create table compute_stats_db.incremental_string_part_value(col int) partitioned by
(p string);
insert into compute_stats_db.incremental_string_part_value partition(p="test_string")
values(2);
compute incremental stats compute_stats_db.incremental_string_part_value
partition(p="test_string");
show table stats compute_stats_db.incremental_string_part_value;
---- RESULTS
'test_string',1,1,'2B','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'Total',1,1,'2B','0B','','','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# Check that dropping a column still allows stats to be computed
create table compute_stats_db.incremental_drop_column (a int, b int, c int)
partitioned by (d int);
alter table compute_stats_db.incremental_drop_column add partition (d=1);
insert into compute_stats_db.incremental_drop_column partition(d=1) values (4,4,4);
compute incremental stats compute_stats_db.incremental_drop_column;
alter table compute_stats_db.incremental_drop_column drop column c;
alter table compute_stats_db.incremental_drop_column drop column b;
compute incremental stats compute_stats_db.incremental_drop_column;
show table stats compute_stats_db.incremental_drop_column;
---- RESULTS
'1',1,1,'6B','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'Total',1,1,'6B','0B','','','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
# Check that adding a column invalidates all incremental stats
create table compute_stats_db.incremental_add_column (col int) partitioned by (p int);
insert into compute_stats_db.incremental_add_column partition(p) values(1,1),(2,2);
compute incremental stats compute_stats_db.incremental_add_column;
insert into compute_stats_db.incremental_add_column partition(p) values(1,1);
alter table compute_stats_db.incremental_add_column add columns (c int);
compute incremental stats compute_stats_db.incremental_add_column;
show table stats compute_stats_db.incremental_add_column;
---- RESULTS
'1',2,2,'4B','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'2',1,1,'2B','NOT CACHED','NOT CACHED','TEXT','true',regex:.*
'Total',3,3,'6B','0B','','','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
create table compute_stats_db.incremental_no_partitions (col int) partitioned by (p int);
compute incremental stats compute_stats_db.incremental_no_partitions;
show table stats compute_stats_db.incremental_no_partitions;
---- RESULTS
'Total',0,0,'0B','0B','','','',''
---- TYPES
STRING, BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
---- QUERY
create table compute_stats_db.incremental_not_partitioned (col int);
insert into compute_stats_db.incremental_not_partitioned values(1),(2);
compute incremental stats compute_stats_db.incremental_not_partitioned;
show table stats compute_stats_db.incremental_not_partitioned;
---- RESULTS
2,1,'4B','NOT CACHED','NOT CACHED','TEXT','false',regex:.*
---- TYPES
BIGINT, BIGINT, STRING, STRING, STRING, STRING, STRING, STRING
====
====
---- QUERY
# IMPALA-1629: Verify that the column stats for CHAR/VARCHAR columns are populated.
# The values of date_string_col always have exactly 8 characters. The CHAR/VARCHAR
# sizes below are chosen such that they are smaller, equal, and greater than the
# source data values, in particular, to test the CHAR padding behavior.
create table compute_stats_db.chars_tbl (
id int,
ch1 char(1),
ch2 char(8),
ch3 char(20),
ts timestamp,
vc1 varchar(1),
vc2 varchar(8),
vc3 varchar(20)
)
partitioned by (
year char(5),
day varchar(13)
);
insert overwrite compute_stats_db.chars_tbl partition(year, day)
select
id,
cast(date_string_col as char(1)),
cast(date_string_col as char(8)),
cast(date_string_col as char(20)),
timestamp_col,
cast(date_string_col as varchar(1)),
cast(date_string_col as varchar(8)),
cast(date_string_col as varchar(20)),
cast(year as char(5)),
cast(day as varchar(13))
from functional.alltypesagg
where day is null or day in (3, 7);
---- RESULTS: VERIFY_IS_EQUAL_SORTED
year=2010 /day=7/: 1000
year=2010 /day=3/: 1000
year=2010 /day=__HIVE_DEFAULT_PARTITION__/: 1000
====
---- QUERY
compute incremental stats compute_stats_db.chars_tbl
---- RESULTS
'Updated 3 partition(s) and 8 column(s).'
---- TYPES
STRING
====
---- QUERY
show column stats compute_stats_db.chars_tbl
---- LABELS
COLUMN, TYPE, #DISTINCT VALUES, #NULLS, MAX SIZE, AVG SIZE
---- RESULTS
'id','INT',2915,-1,4,4
'ch1','CHAR(1)',1,-1,1,1
'ch2','CHAR(8)',10,-1,8,8
'ch3','CHAR(20)',10,-1,8,8
'ts','TIMESTAMP',2871,-1,16,16
'vc1','VARCHAR(1)',1,-1,1,1
'vc2','VARCHAR(8)',10,-1,8,8
'vc3','VARCHAR(20)',10,-1,8,8
'year','CHAR(5)',1,0,5,5
'day','VARCHAR(13)',3,1,-1,-1
---- TYPES
STRING, STRING, BIGINT, BIGINT, INT, DOUBLE
====
---- QUERY
# Populate a new partition to verify the incremental stats update
insert into compute_stats_db.chars_tbl partition(year, day)
select null, cast('x' as char(1)), cast('x' as char(8)), cast('x' as char(20)),
null, cast('x' as varchar(1)), cast('x' as varchar(8)), cast('x' as varchar(20)),
cast('abc' as char(5)), cast('xyz' as varchar(13));
compute incremental stats compute_stats_db.chars_tbl;
---- RESULTS
'Updated 1 partition(s) and 8 column(s).'
---- TYPES
STRING
====
---- QUERY
show column stats compute_stats_db.chars_tbl
---- LABELS
COLUMN, TYPE, #DISTINCT VALUES, #NULLS, MAX SIZE, AVG SIZE
---- RESULTS
'id','INT',2915,-1,4,4
'ch1','CHAR(1)',2,-1,1,1
'ch2','CHAR(8)',11,-1,8,7.99766731262207
'ch3','CHAR(20)',11,-1,8,7.99766731262207
'ts','TIMESTAMP',2871,-1,16,16
'vc1','VARCHAR(1)',2,-1,1,1
'vc2','VARCHAR(8)',11,-1,8,7.99766731262207
'vc3','VARCHAR(20)',11,-1,8,7.99766731262207
'year','CHAR(5)',2,0,5,5
'day','VARCHAR(13)',4,1,-1,-1
---- TYPES
STRING, STRING, BIGINT, BIGINT, INT, DOUBLE
====