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

相关推荐
森山冶仁5 天前
AI 原生数据治理技术栈:大模型 + 向量库 + 知识图谱怎么选
人工智能·知识图谱·数据治理
Aloudata5 天前
数据治理台账 vs 元数据知识图谱:数据资产如何从文档走向计算化
数据库·人工智能·知识图谱·数据治理·元数据·数据资产·数据血缘
千桐科技6 天前
DataX组件扩展、任务日志优化与部署能力完善,qData开源版数据中台V1.6.1版本解析!
大数据·开源·数据治理·开源项目·数据中台·qdata
亿信华辰软件9 天前
边对话、边治理、边学习——数据治理的下一代范式
人工智能·数据治理
hzp66611 天前
Hudi 1:表类型COW和MOR,Primary Key 与 Partition
hudi·cow·mor·recordkey
DataX_ruby8211 天前
化工行业数据治理实战:数据中台如何实现安全、环保与生产三域数据融合分析
数据治理·数据中台
hzp66612 天前
hudi学习0:目录
大数据·hudi
千桐科技13 天前
开源共建数字水利生态:千桐科技智慧水利项目正式上线 Gitee,诚邀开发者参与共建!
大数据·开源·数据治理·开源项目·数字水利
数据分析小兵17 天前
金融数据分类分级实战系列四:如何实现AI自动分级
人工智能·数据治理·数据安全·数据分类分级·ai大模型·数据中台·智能体
竹枝溪18 天前
MySQL数据库零基础入门
数据库·sql·mysql·navicat·ddl·dml·dql