# Impala和Inceptor的区别 # 1、Impala建表时存储方式是parquet,Inceptor建表时的存储方式是ORC
# Impala建表:
drop table if exists dsc_bas.t_bjhg_dymx;
create table dsc_bas.t_bjhg_dymx
(
? ? `khh` string comment '客户号',
? ? `jys` string comment '交易所',
?? ?`gdh` string comment '股东号',
?? ?`xwdm` string comment '席位号',
?? ?`zyq` string comment '质押券',
?? ?`dysl` decimal(22,2) comment '质押数量',
?? ?`zt` string comment '状态',
?? ?`cjrq` int comment '成交日期',
?? ?`cjbh` string comment '成交编号',
?? ?`sjlx` string comment '数据类型',
?? ?`yyb` string comment '营业部'
)comment '报价回购_抵押明细'
clustered by (khh) sorted by (khh asc) into 4 buckets
stored as parquet;
# Inceptor建表:
drop table if exists dsc_bas.t_bjhg_dymx;
create table dsc_bas.t_bjhg_dymx
(
? ? `khh` string comment '客户号',
? ? `jys` string comment '交易所',
?? ?`gdh` string comment '股东号',
?? ?`xwdm` string comment '席位号',
?? ?`zyq` string comment '质押券',
?? ?`dysl` decimal(22,2) comment '质押数量',
?? ?`zt` string comment '状态',
?? ?`cjrq` int comment '成交日期',
?? ?`cjbh` string comment '成交编号',
?? ?`sjlx` string comment '数据类型',
?? ?`yyb` string comment '营业部'
)comment '报价回购_抵押明细'
clustered by (khh) sorted by (khh asc) into 4 buckets
stored as ORC;
#2、插入方式的不同 # insert overwrite时,Inceptor需要加上关键字table,Impala不需要
Impala插入数据:
insert overwrite dsc_cfg.t_zqdm
(jys,jyzt,bz,gt_zqlb)
select udfs.f_get_etl_tran_dicval
? ? ?(dsc_cfg,t_zqdm,jys,1,1,a.jys) as jys,
? ? ? cast(jyzt as string) as jyzt,
? ? ? udfs.f_get_etl_tran_dicval(dsc_cfg,t_zqdm,bz,1,1,a.bz) as bz,
? ? ? zqlb as gt_zqlb
from src_aboss.tzqdm a;
Inceptor插入数据:
insert overwrite table dsc_cfg.t_zqdm
(jys,jyzt,bz,gt_zqlb)
select udfs.f_get_etl_tran_dicval
? ? ?(dsc_cfg,t_zqdm,jys,1,1,a.jys) as jys,
? ? ? cast(jyzt as string) as jyzt,
? ? ? udfs.f_get_etl_tran_dicval(dsc_cfg,t_zqdm,bz,1,1,a.bz) as bz,
? ? ? zqlb as gt_zqlb
from src_aboss.tzqdm a;
#3、udf函数的使用方式不同 Inceptor中不需要udfs.前缀,单个查询时需要指定from system.dual
Impala使用udf函数:
select udfs.f_get_jyr_date(20180102,-1);
Inceptor使用udf函数:
select .f_get_jyr_date(20180102,-1) from system.dual;
#4、变量传递方式不同 Inceptor在脚本中传递变量通过-hivevar name=value,Impala通过-var=“name=value”
Impala:
impala-shell -i 10.2.1.55 -l -udingdian \
-- ldap_password_cmd="echo -n dingdian_123" \
-- auth_creds_ok_in_clear -f p_stat_kh_yjfl.sql \
-- var="RQ=20180731"
SQL:${VAR:RQ}
Inceptor:
beeline -u jdbc:hive2://192.168.166.237:10000/default \
-n dingdian -p 123456 -f p_tran_zqhq_his.sql \
--hivevar rq=20180628
SQL:${hivevar:rq}
#5、分区表插入方式不同 插入分区时:Inceptor中partition 需要紧跟在表名后面,之后再指定列名,而Impala则是表名后面跟列名,再跟partition
Impala:
insert overwrite table dsc_bas.t_zqhq_his(jys) partition (rq=${var:rq})
select udfs.f_get_etl_tran_dicval('dsc_bas','t_zqhq_his','jys',1,1,a.jys) as jys
from src_aboss.tzqhq a
where a.rq=${VAR:RQ};
Inceptor:
insert overwrite table dsc_bas.t_zqhq_his partition (rq=${hivevar:rq}) (jys)
select udfs.f_get_etl_tran_dicval('dsc_bas','t_zqhq_his','jys',1,1,a.jys) as jys
from src_aboss.tzqhq a
where a.rq=${hivevar:RQ};
#6、with...as用法不同 Impala 用insert后接with..as中间可以写字段名,也可以省略,而Inceptor用insert后接with..as 中间不可以写字段名
impala:
insert into table temp.tmp_stat_nonekh_zb_yyb_fwkhs_01(u_id,sjdw,sjz,zbdm,zbz,ys_id,cj)
with temp_yyb_fwkhs_R as (select....) select ....
Inceptor:
insert into table temp.tmp_stat_nonekh_zb_yyb_fwkhs_01
with temp_yyb_fwkhs_R as (select....) select ....
|