Hive外部分区表
建表语句
create external table xxx(
xxx int,
xxx string,
xxx array<bigint>,
xxx struct<aaa:string,bbb:string>
)
partitioned by(pk string) # 分区
row format delimited fields terminated by ',' # 按逗号分隔, text存储时使用
row format serde 'org.apache.hadoop.hive.serde2.JsonSerDe' # json格式的话加上这条, stored选textfile
stored as parquet # 五种类型可选, textfile, sequencefile, rcfile, orcfile, parquet
location '数据地址'
常用命令
# 修复分区
msck repair table xxx;
# 添加/删除分区
alter table xxx add partition(pk='xxx') location 'xxxx';
alter table xxx drop partition(pk='xxx');
# 查看分区
show partitions xxx;
# 查看分区结构
desc formatted xxx;
# 查看建表语句
show create table xxxx;
# 查看表字段
describe table;
创建view
kylin只能导入扁平化hive表, 不支持hive复杂数据类型, 导入进去不显示
可通过创建view拍平复杂字段
create view if not exist