1. 创建parquet table :
create table mytable(a int,b int) STORED AS PARQUET;
2. 创建带压缩的parquet table:
create table mytable(a int,b int) STORED AS PARQUET TBLPROPERTIES('parquet.compression'='SNAPPY');
3. 如果原来创建表的时候没有指定压缩,后续可以通过修改表属性的方式添加压缩:
ALTER TABLE mytable SET TBLPROPERTIES ('parquet.compression'='SNAPPY');

或者在写入的时候
set parquet.compression=SNAPPY;不过只会影响后续入库的数据,原来的数据不会被压缩,需要重跑原来的数据。
采用压缩之后大概可以降低1/3的存储大小。
-------------------------------------------------------- 合并 --------------------------------------------------------
-- set hive.execution.engine=tez;
-- set tez.queue.name=dtb_matter;
set hive.execution.engine=mr;
set mapred.job.queue.name=dw;
set hive.exec.parallel=true;
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
drop table tmp_dim.dim_ch;
create table tmp_dim.dim_ch stored as parquet as
select
...
-- 临时表 保留7天分区
-- alter table dim.dim_tb_name drop partition (inc_day = '$[time(yyyyMMdd,-7d)]');
















