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

相关推荐
Light602 天前
《中国电力产业数字化》深度解析与前沿展望(下)——中国电力数字化转型路线图:SPARK 融合平台的设计与落地方案
数据治理·ipaas·apaas·权限一体化·接口契约·能力包
胡耀超2 天前
大数据平台安全指南——大数据平台安全架构全景:从认证授权到数据治理的企业级实践指南——认证、授权、审计、加密四大支柱
安全·数据治理·数据安全·权限管理·安全架构·hadoop生态·合规审计
fanstuck3 天前
开源项目重构我们应该怎么做-以 SQL 血缘系统开源项目为例
数据库·sql·重构·数据挖掘·数据治理
Jolie_Liang4 天前
金融领域数据治理与隐私保护研究报告
数据治理
数据要素X8 天前
寻梦数据空间 | 架构篇:从概念到落地的技术实践与突破性创新
大数据·运维·数据仓库·微服务·数据治理·数据中台·可信数据空间
数据要素X15 天前
【大数据实战】如何从0到1构建用户画像系统(案例+数据仓库+Airflow调度)
大数据·数据仓库·数据治理·数据中台
王百万_24 天前
【浅谈Spark和Flink区别及应用】
大数据·数据库·分布式·flink·spark·数据治理·数据库架构
千桐科技1 个月前
轻松上手 qData 数据中台开源版:Docker Compose 助你10分钟跑起来
数据治理·大数据平台·qdata·开源数据中台·千数平台·java数据中台·qdata数据中台
袋鼠云数栈1 个月前
袋鼠云产品功能更新报告14期|实时开发,效率再升级!
经验分享·数据治理·数字孪生·空间智能·数据智能·产品升级·数字孪生产品
友莘居士2 个月前
Apache DolphinScheduler:数据治理中数据质检利器
apache·数据治理·dolphin·数据质量·scheduler·数据质检