Skip to content

Instantly share code, notes, and snippets.

CREATE TABLE my_database.my_table
(
column_1 string,
column_2 int,
column_3 double
)
PARTITIONED BY
(
year int,
month smallint,
CREATE TABLE my_database.my_table
(
column_1 string,
column_2 int,
column_3 double
)
PARTITIONED BY
(
year int,
month smallint,
ANALYZE TABLE my_database.my_table compute statistics;
ANALYZE TABLE my_database.my_table PARTITION (YEAR=2017, MONTH=11, DAY=30) compute statistics;
ANALYZE TABLE my_database.my_table compute statistics for column1, column2, column3; -- column stats for non-partitioned table
ANALYZE TABLE my_database.my_table PARTITION (YEAR=2017, MONTH=11, DAY=30, HOUR=0) compute statistics for column1, column2, column3; -- column stats for single hour of partitioned table
ANALYZE TABLE my_database.my_table PARTITION (YEAR=2017, MONTH=11, DAY=30, HOUR) compute statistics for column1, column2, column3; -- column stats for a single day of partitioned table
set hive.compute.query.using.stats=true;
set hive.stats.fetch.column.stats=true;
select * from my_table
limit 10000;
select * from my_table
order by rand()
limit 10000;
select * from my_table
sort by rand()
limit 10000;
select * from my_table
distribute by rand()
sort by rand()
limit 10000;