【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类型。

相关推荐
vx153027823622 天前
CDGA|AI时代,数据治理的位置下沉了吗?
大数据·人工智能·cdga·数据治理
DataX_ruby823 天前
企业数据中台选型:高适配性怎么评估,从三个维度到五个确认项
数据治理·数据中台
axe_hu3 天前
从 POC 到规模化:企业 AI 转型卡在哪一步
数据治理·组织变革·模型运维
西木莉3 天前
中小企业知识管理的核心难点?
数据治理
森山冶仁4 天前
数据飞轮的企业版切入:四个环节先做哪个
人工智能·数据治理·数据要素·数据质量·数据资产
不剪发的Tony老师5 天前
Apache Atlas:一个企业级元数据管理和数据治理平台
数据治理·元数据管理·数据血缘
森山冶仁6 天前
数据资源科目第一次“缩表”:8.49 亿背后的新增、摊销与减值
数据治理·数据资产·无形资产·数据资源入表·财报合规
dyj0958 天前
基于 DAMA 数据治理体系的高校数据治理方案
大数据·数据治理
袋鼠云数栈9 天前
让 SQL 解析不再重复造轮子:SqlParserX 正式开源
数据库·人工智能·sql·开源·数据治理
zxsz_com_cn12 天前
预测性维护数据的 ownership 之争:设备部还是IT部?
数据治理·工业4.0·预测性维护·组织协同·跨部门