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

相关推荐
hf2000121 天前
美团 x 云器|从美团BI平台升级看数据引擎架构升级演进路径
架构·数据湖·湖仓一体·lakehouse
唐可盐2 天前
【数据治理实践】第 2 期:顶层设计之数据战略
数据治理
F36_9_2 天前
大数据治理平台选型避坑:2026 年 8 大主流系统实测
大数据·数据治理
光于前裕于后3 天前
配置钉钉龙虾OpenClaw机器人调用OpenMetadata
机器人·钉钉·数据治理·mcp·openclaw
SelectDB技术团队5 天前
PostgreSQL + Apache Doris:构建用于实时分析的 HTAP 架构
数据库·postgresql·架构·实时数仓·湖仓一体·apache doris·selectdb
老徐电商数据笔记9 天前
一个典型的基于 Apache Paimon 的湖仓一体架构图
apache·湖仓一体·paimon·湖仓
龙石数据10 天前
《数据治理实战指南》【第三部分 实施篇】第11章 主数据管理
数据治理·数据中台·主数据管理·《数据治理实战指南》
袋鼠云数栈11 天前
能源矿产行业 Data + AI 数智化全景解决方案——构建集团级智慧运营生产体系的系统路径
大数据·人工智能·能源·数据治理
RestCloud12 天前
ETL与数据湖Hudi的集成与操作
数据仓库·etl·hudi·数据同步·数据集成平台
Light601 个月前
不止于名:领码 SPARK 如何“链”动数据仓库、数据湖、中台与湖仓一体新纪元
大数据·数据仓库·数据湖·ipaas·湖仓一体·数据中台·领码 spark