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

相关推荐
衡石科技2 天前
指标管理平台选型指南:四个评估维度与一份验证清单
数据治理·指标平台·指标管理·ai bi·选型指南
明航咨询_贾老师3 天前
DCMM 2.0落地实操深度拆解|从数据治理到数据资产化,五步走框架与三个核心能力
数据治理
大大大大晴天️3 天前
大数据数据治理体系建设:从平台能力到组织闭环的完整蓝图
大数据·数据治理
Patrick在香港4 天前
Python 审计香港开放数据目录:两个端点差 10 倍,只有 9.3% 的资源标了「最后修改时间」
开发语言·数据库·python·数据分析·api·数据治理·开放数据
物联网IoT小易7 天前
物联网设备数据异常怎么处理?重复、乱序、断点续传与脏数据治理
物联网·mqtt·数据治理·时序数据库·物联网设备·物联网设备接入·物联网设备连接
大大大大晴天️10 天前
从数仓建模到 AI 数据底座:重新理解数据治理的位置
大数据·数据治理
沙淘金数据服务10 天前
电商订单数据整合难题拆解:多源异构数据如何实现自动化治理?
大数据·人工智能·数据治理·数据清洗·电商·外贸
千桐科技12 天前
qData 开源版数据中台 v1.6.2 上线:修复数据连接、元数据与项目管理等多项问题
大数据·开源·数据治理·数据可视化·数据中台·元数据·qdata
袋鼠云数栈13 天前
实时湖仓如何真正做到“数据够新”?
大数据·数据库·人工智能·数据治理
灰灰202614 天前
政务数据分类分级:从零梳理、目录搭建、验收标准全解
数据治理·数据合规·数据目录·政务数据分类分级·政务数据安全·密评等保·政务项目建设