mirror of
https://github.com/apache/impala.git
synced 2026-01-05 12:01:11 -05:00
Adds the TABLESAMPLE clause for COMPUTE STATS.
Syntax:
COMPUTE STATS <table> TABLESAMPLE SYSTEM(<number>) [REPEATABLE(<number>)]
Computes and replaces the table-level row count and total file size,
as well as all table-level column statistics. Existing partition-level
row counts are not modified.
The TABLESAMPLE clause can be used to limit the scanned data volume to
a desired percentage. When sampling, the unmodified results of the
COMPUTE STATS queries are sent to the CatalogServer. There, the stats
are extrapolated before storing them into the HMS so as not to confuse
other engines like Hive/SparkSQL which may rely on the shared HMS
fields being accurate.
Limitations
- Only works for HDFS tables
- TABLESAMPLE is not supported for COMPUTE INCREMENTAL STATS
- TABLESAMPLE requires --enable_stats_extrapolation=true
Changes to EXPLAIN
The stored statistics from the HMS are more clearly displayed under
a 'stored statistics' section. Example:
00:SCAN HDFS [functional.alltypes, RANDOM]
partitions=24/24 files=24 size=478.45KB
stored statistics:
table: rows=7300 size=478.45KB
partitions: 24/24 rows=7300
columns: all
Testing:
- added new functional tests
- core/hdfs run passed
Change-Id: I7f3e72471ac563adada4a4156033a85852b7c8b7
Reviewed-on: http://gerrit.cloudera.org:8080/8136
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: Impala Public Jenkins
138 lines
6.2 KiB
Plaintext
138 lines
6.2 KiB
Plaintext
====
|
|
---- QUERY
|
|
compute stats alltypes tablesample system (50) repeatable (1)
|
|
---- RESULTS
|
|
'Updated 1 partition(s) and 11 column(s).'
|
|
---- TYPES
|
|
STRING
|
|
====
|
|
---- QUERY
|
|
# Only the table-level row count is stored. The partition row counts are extrapolated.
|
|
show table stats alltypes
|
|
---- LABELS
|
|
YEAR, MONTH, #ROWS, EXTRAP #ROWS, #FILES, SIZE, BYTES CACHED, CACHE REPLICATION, FORMAT, INCREMENTAL STATS, LOCATION
|
|
---- RESULTS
|
|
'2009','1',-1,305,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=1'
|
|
'2009','2',-1,277,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=2'
|
|
'2009','3',-1,306,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=3'
|
|
'2009','4',-1,299,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=4'
|
|
'2009','5',-1,311,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=5'
|
|
'2009','6',-1,301,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=6'
|
|
'2009','7',-1,311,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=7'
|
|
'2009','8',-1,311,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=8'
|
|
'2009','9',-1,301,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=9'
|
|
'2009','10',-1,311,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=10'
|
|
'2009','11',-1,301,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=11'
|
|
'2009','12',-1,311,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=12'
|
|
'Total','',3643,3643,12,regex:.*B,'0B','','','',''
|
|
---- TYPES
|
|
STRING,STRING,BIGINT,BIGINT,BIGINT,STRING,STRING,STRING,STRING,STRING,STRING
|
|
====
|
|
---- QUERY
|
|
show column stats alltypes
|
|
---- LABELS
|
|
COLUMN, TYPE, #DISTINCT VALUES, #NULLS, MAX SIZE, AVG SIZE
|
|
---- RESULTS
|
|
'id','INT',3643,-1,4,4
|
|
'bool_col','BOOLEAN',2,-1,1,1
|
|
'tinyint_col','TINYINT',17,-1,1,1
|
|
'smallint_col','SMALLINT',17,-1,2,2
|
|
'int_col','INT',17,-1,4,4
|
|
'bigint_col','BIGINT',17,-1,8,8
|
|
'float_col','FLOAT',17,-1,4,4
|
|
'double_col','DOUBLE',17,-1,8,8
|
|
'date_string_col','STRING',364,-1,8,8
|
|
'string_col','STRING',17,-1,1,1
|
|
'timestamp_col','TIMESTAMP',3612,-1,16,16
|
|
'year','INT',1,0,4,4
|
|
'month','INT',12,0,4,4
|
|
---- TYPES
|
|
STRING,STRING,BIGINT,BIGINT,BIGINT,DOUBLE
|
|
====
|
|
---- QUERY
|
|
# Repeat tests on a very small sample.
|
|
compute stats alltypes tablesample system (1) repeatable (1)
|
|
---- RESULTS
|
|
'Updated 1 partition(s) and 11 column(s).'
|
|
---- TYPES
|
|
STRING
|
|
====
|
|
---- QUERY
|
|
show table stats alltypes
|
|
---- LABELS
|
|
YEAR, MONTH, #ROWS, EXTRAP #ROWS, #FILES, SIZE, BYTES CACHED, CACHE REPLICATION, FORMAT, INCREMENTAL STATS, LOCATION
|
|
---- RESULTS
|
|
'2009','1',-1,304,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=1'
|
|
'2009','2',-1,276,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=2'
|
|
'2009','3',-1,305,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=3'
|
|
'2009','4',-1,298,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=4'
|
|
'2009','5',-1,310,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=5'
|
|
'2009','6',-1,300,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=6'
|
|
'2009','7',-1,310,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=7'
|
|
'2009','8',-1,310,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=8'
|
|
'2009','9',-1,300,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=9'
|
|
'2009','10',-1,310,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=10'
|
|
'2009','11',-1,300,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=11'
|
|
'2009','12',-1,310,1,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/alltypes/year=2009/month=12'
|
|
'Total','',3633,3633,12,regex:.*B,'0B','','','',''
|
|
---- TYPES
|
|
STRING,STRING,BIGINT,BIGINT,BIGINT,STRING,STRING,STRING,STRING,STRING,STRING
|
|
====
|
|
---- QUERY
|
|
show column stats alltypes
|
|
---- LABELS
|
|
COLUMN, TYPE, #DISTINCT VALUES, #NULLS, MAX SIZE, AVG SIZE
|
|
---- RESULTS
|
|
'id','INT',3633,-1,4,4
|
|
'bool_col','BOOLEAN',2,-1,1,1
|
|
'tinyint_col','TINYINT',117,-1,1,1
|
|
'smallint_col','SMALLINT',117,-1,2,2
|
|
'int_col','INT',117,-1,4,4
|
|
'bigint_col','BIGINT',117,-1,8,8
|
|
'float_col','FLOAT',117,-1,4,4
|
|
'double_col','DOUBLE',117,-1,8,8
|
|
'date_string_col','STRING',352,-1,8,8
|
|
'string_col','STRING',117,-1,1,1
|
|
'timestamp_col','TIMESTAMP',3633,-1,16,16
|
|
'year','INT',1,0,4,4
|
|
'month','INT',12,0,4,4
|
|
---- TYPES
|
|
STRING,STRING,BIGINT,BIGINT,BIGINT,DOUBLE
|
|
====
|
|
---- QUERY
|
|
# Test unpartitioned table.
|
|
compute stats alltypesnopart tablesample system (10) repeatable (999)
|
|
---- RESULTS
|
|
'Updated 1 partition(s) and 11 column(s).'
|
|
---- TYPES
|
|
STRING
|
|
====
|
|
---- QUERY
|
|
show table stats alltypesnopart
|
|
---- LABELS
|
|
#ROWS, EXTRAP #ROWS, #FILES, SIZE, BYTES CACHED, CACHE REPLICATION, FORMAT, INCREMENTAL STATS, LOCATION
|
|
---- RESULTS
|
|
3660,3660,12,regex:.*B,'NOT CACHED','NOT CACHED','TEXT','false','$NAMENODE/test-warehouse/$DATABASE.db/alltypesnopart'
|
|
---- TYPES
|
|
BIGINT,BIGINT,BIGINT,STRING,STRING,STRING,STRING,STRING,STRING
|
|
====
|
|
---- QUERY
|
|
show column stats alltypesnopart
|
|
---- LABELS
|
|
COLUMN, TYPE, #DISTINCT VALUES, #NULLS, MAX SIZE, AVG SIZE
|
|
---- RESULTS
|
|
'id','INT',3660,-1,4,4
|
|
'bool_col','BOOLEAN',2,-1,1,1
|
|
'tinyint_col','TINYINT',63,-1,1,1
|
|
'smallint_col','SMALLINT',63,-1,2,2
|
|
'int_col','INT',63,-1,4,4
|
|
'bigint_col','BIGINT',63,-1,8,8
|
|
'float_col','FLOAT',63,-1,4,4
|
|
'double_col','DOUBLE',63,-1,8,8
|
|
'date_string_col','STRING',360,-1,8,8
|
|
'string_col','STRING',63,-1,1,1
|
|
'timestamp_col','TIMESTAMP',3660,-1,16,16
|
|
---- TYPES
|
|
STRING,STRING,BIGINT,BIGINT,BIGINT,DOUBLE
|
|
====
|