是聚合模型表,排序键为分区字段f_p_date和分桶键forder_id,分桶数20。
以下是建表语句:
CREATE TABLE test_dws.dws_ord_order_info_hf
(
f_p_date date NOT NULL ,
forder_id string NOT NULL ,
fpay_way int REPLACE_IF_NOT_NULL ,
fcreate_time_odtoi datetime REPLACE_IF_NOT_NULL ,
ftotal_amount_odtoi decimal(15,2) REPLACE_IF_NOT_NULL ,
ftotal_firstpay_odtoi decimal(15,2) REPLACE_IF_NOT_NULL ,
finner_flag int REPLACE_IF_NOT_NULL ,
fuid_odtoi int REPLACE_IF_NOT_NULL ,
fmax_fq_num_odtoi int REPLACE_IF_NOT_NULL ,
forder_state_odtoi int REPLACE_IF_NOT_NULL ,
forder_type_odtoi int REPLACE_IF_NOT_NULL ,
factual_year_ratio_odtoi decimal(4,4) REPLACE_IF_NOT_NULL ,
fbefore_year_ratio_odtoi decimal(4,4) REPLACE_IF_NOT_NULL ,
faccount_date_odtoi string REPLACE_IF_NOT_NULL ,
ffee_ratio decimal(6,6) REPLACE_IF_NOT_NULL ,
forder_id_cclodtlo string REPLACE_IF_NOT_NULL ,
fmax_fq_num_cclodtlo string REPLACE_IF_NOT_NULL ,
fcreate_time_cclodtlo datetime REPLACE_IF_NOT_NULL ,
ftotal_amount_cclodtlo decimal(15,2) REPLACE_IF_NOT_NULL ,
fuid_cclodtlo int REPLACE_IF_NOT_NULL ,
fbusiness_own_cclodtlo string REPLACE_IF_NOT_NULL ,
factual_year_ratio_cclodtlo decimal(4,4) REPLACE_IF_NOT_NULL ,
fbefore_year_ratio_cclodtlo decimal(4,4) REPLACE_IF_NOT_NULL ,
forder_type_cclodtlo int REPLACE_IF_NOT_NULL ,
forder_state_cclodtlo int REPLACE_IF_NOT_NULL ,
forder_id_ocdtoci string REPLACE_IF_NOT_NULL ,
fmax_fq_num_ocdtoci string REPLACE_IF_NOT_NULL ,
fcreate_time_ocdtoci datetime REPLACE_IF_NOT_NULL ,
ftotal_amount_ocdtoci decimal(15,2) REPLACE_IF_NOT_NULL ,
fuid_ocdtoci int REPLACE_IF_NOT_NULL ,
fbusiness_own_ocdtoci string REPLACE_IF_NOT_NULL ,
factual_year_ratio_ocdtoci decimal(4,4) REPLACE_IF_NOT_NULL ,
fbefore_year_ratio_ocdtoci decimal(4,4) REPLACE_IF_NOT_NULL ,
forder_type_ocdtoci int REPLACE_IF_NOT_NULL ,
forder_state_ocdtoci int REPLACE_IF_NOT_NULL ,
fcreate_time datetime REPLACE_IF_NOT_NULL ,
ftotal_amount decimal(15,2) REPLACE_IF_NOT_NULL ,
floan_amount decimal(15,2) REPLACE_IF_NOT_NULL ,
fuid int REPLACE_IF_NOT_NULL ,
fis_test_order int REPLACE_IF_NOT_NULL ,
fis_loan_order_flag int REPLACE_IF_NOT_NULL ,
fmax_fq_num int REPLACE_IF_NOT_NULL ,
forder_state int REPLACE_IF_NOT_NULL ,
fbefore_year_ratio decimal(4,4) REPLACE_IF_NOT_NULL ,
factual_year_ratio decimal(4,4) REPLACE_IF_NOT_NULL ,
fis_first_flag int REPLACE_IF_NOT_NULL ,
ffirst_create_time datetime REPLACE_IF_NOT_NULL ,
ftrans_mob string REPLACE_IF_NOT_NULL ,
fis_platform_succ_flag1 int REPLACE_IF_NOT_NULL ,
fnew_order_user_type string REPLACE_IF_NOT_NULL ,
forder_type int REPLACE_IF_NOT_NULL ,
focnt int REPLACE_IF_NOT_NULL ,
fucnt int REPLACE_IF_NOT_NULL ,
fis_tj_order_flag int REPLACE_IF_NOT_NULL ,
fsale_type_odtoi int REPLACE_IF_NOT_NULL ,
fsku_id_odtoi string REPLACE_IF_NOT_NULL ,
fextend_info_odtoi string REPLACE_IF_NOT_NULL ,
fis_maiya_flag int REPLACE_IF_NOT_NULL ,
fmerch_id_pdtpo string REPLACE_IF_NOT_NULL ,
fcreate_time_pdtpo datetime REPLACE_IF_NOT_NULL ,
fmerch_id_aoodtoi string REPLACE_IF_NOT_NULL ,
fcreate_time_aoodtoi datetime REPLACE_IF_NOT_NULL ,
fetl_time DATETIME MAX,
flast_modify_time DATETIME MAX
)AGGREGATE KEY(f_p_date,forder_id)
PARTITION BY RANGE(f_p_date)(
START ("2013-01-01") END ("2021-01-01") EVERY (INTERVAL 1 YEAR),
START ("2021-01-01") END ("2022-01-01") EVERY (INTERVAL 1 MONTH),
START ("2022-01-01") END ("2022-07-01") EVERY (INTERVAL 1 day)
)
DISTRIBUTED BY HASH(forder_id) BUCKETS 20
PROPERTIES(
-- "colocate_with" = "order_cg",
"dynamic_partition.enable" = "true",
"dynamic_partition.time_unit" = "DAY",
"dynamic_partition.end" = "3",
"dynamic_partition.prefix" = "p",
"dynamic_partition.buckets" = "20",
"replication_num"="3");