【Hudi-SQL DDL创建表语法】

CREATE TABLE

命令功能

CREATE TABLE命令通过指定带有表属性的字段列表来创建Hudi Table。

命令格式

bash 复制代码
CREATE TABLE [ IF NOT EXISTS] [database_name.]table_name

[ (columnTypeList)]

USING hudi

[ COMMENT table_comment ]

[ LOCATION location_path ]

[ OPTIONS (options_list) ]

参数描述

表1 CREATE TABLE参数描述

表2 CREATE TABLE Options描述

示例

•创建非分区表-- 创建一个cow内部表

bash 复制代码
create table if not exists hudi_table0 (
id int,
name string,
price double
)  using hudi
options (
type = 'cow',
primaryKey = 'id'
);

-- 创建一个mor外部表

bash 复制代码
create table if not exists hudi_table1 (
id int,
name string,
price double,
ts bigint
)  using hudi
location '/tmp/hudi/hudi_table1'
options (
type = 'mor',
primaryKey = 'id,name',
preCombineField = 'ts'
);

•创建分区表

bash 复制代码
create table if not exists hudi_table_p0 (
id bigint,
name string,
ts bigint,
dt string,
hh string
)  using hudi
location '/tmp/hudi/hudi_table_p0'
options (
type = 'cow',
primaryKey = 'id',
preCombineField = 'ts'
)
partitioned by (dt, hh);

•以SQL方式创建一个hudi表的外表,与spark-shell or deltastreamer方式创建的hudi外表相同

bash 复制代码
create table h_p1
using hudi
options (
primaryKey = 'id',
preCombineField = 'ts'
)
partitioned by (dt)
location '/path/to/hudi';

•创建表指定表属性

bash 复制代码
create table if not exists h3(
id bigint,
name string,
price double
) using hudi
options (
primaryKey = 'id',
type = 'mor',
hoodie.cleaner.fileversions.retained = '20',
hoodie.keep.max.commits = '20'
);

注意事项

Hudi当前不支持使用char、varchar、tinyint、smallint类型,建议使用string或int类型。

相关推荐
森山冶仁7 天前
血缘不准,成本就分不对:表级血缘覆盖率的四次抽验与三条补链办法
数据治理·元数据·数据资产·数据血缘·成本分摊
隔窗听雨眠11 天前
数据质量度量体系与治理闭环的工程实践
数据治理·数据质量·数据平台
隔窗听雨眠11 天前
数据库访问权限治理的分层设计与落地实践
数据治理·权限管理·数据库安全
AllData公司负责人15 天前
【产品便捷使用一】AIIData 数据中台:企业基础版核心能力支持,一站式全链路数据处理实操指南
大数据·前端·数据治理·数据可视化·数据开发·数据服务·数据接入
vx1530278236222 天前
CDGA|AI时代,数据治理的位置下沉了吗?
大数据·人工智能·cdga·数据治理
DataX_ruby8223 天前
企业数据中台选型:高适配性怎么评估,从三个维度到五个确认项
数据治理·数据中台
axe_hu23 天前
从 POC 到规模化:企业 AI 转型卡在哪一步
数据治理·组织变革·模型运维
西木莉23 天前
中小企业知识管理的核心难点?
数据治理
森山冶仁24 天前
数据飞轮的企业版切入:四个环节先做哪个
人工智能·数据治理·数据要素·数据质量·数据资产
不剪发的Tony老师25 天前
Apache Atlas:一个企业级元数据管理和数据治理平台
数据治理·元数据管理·数据血缘