Skip to content

Instantly share code, notes, and snippets.

select * from my_table
order by rand()
limit 10000;
select * from my_table
limit 10000;
set hive.compute.query.using.stats=true;
set hive.stats.fetch.column.stats=true;
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
ANALYZE TABLE my_database.my_table PARTITION (YEAR=2017, MONTH=11, DAY=30) compute statistics;
ANALYZE TABLE my_database.my_table compute statistics;
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,
CREATE TABLE my_database.my_table
STORED AS ORC TBLPROPERTIES('ORC.COMPRESS'='SNAPPY') as
SELECT * FROM my_database.my_other_table WHERE YEAR=2017 AND MONTH=11 AND DAY=30;
CREATE TABLE my_database.my_table
(
column_1 string,
column_2 int,
column_3 double
)
STORED AS ORC
TBLPROPERTIES('ORC.COMPRESS'='SNAPPY'); -- ensure SNAPPY is uppercase, lowercase triggers a nasty bug in Hive (fixed in later versions)