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

相关推荐
俊哥大数据1 天前
基于 FlinkSQL + Paimon + Doris 的车联网流批一体湖仓实践 —— 第 1 章 业务背景与传统 Lambda 架构痛点
大数据·doris·湖仓一体·flinksql·paimon
俊哥大数据1 天前
基于 FlinkSQL + Paimon + Doris 的车联网流批一体湖仓实践 —— 第 2 章 流批一体湖仓总体架构与三条分区契约铁律
flink·doris·湖仓一体·paimon
俊哥大数据1 天前
基于 FlinkSQL + Paimon + Doris 的车联网流批一体湖仓实践 —— 第 4 章 Kafka 企标报文入湖(ODS 表设计)
flink·doris·湖仓一体·paimon·流批一体
俊哥大数据1 天前
基于 FlinkSQL + Paimon + Doris 的车联网流批一体湖仓实践 —— 第 3 章 Paimon 1.4 湖仓底座与 Catalog 配置
flink·doris·湖仓一体·paimon
zhenye19862 天前
《Web 3.0时代数据资产管理》——学习笔记
数据治理
森山冶仁4 天前
数据资产摊销年限与减值测试实操:从“一律三年”到按授权期限与迭代频率估计
数据治理·数据资产·数据资产入表·无形资产摊销·减值测试
制造数据与AI践行者老蒋4 天前
智联工坊实战:工业数据质量自动检测方案 3σ 原则 + Agent 编排 + 分层容错完整实践
数据治理·ai agent·智能工厂·工业大数据·python实战·制造业数据·数据质量巡检
森山冶仁5 天前
EU AI Act 第 10 条落地前:训练数据的治理文档怎么准备
数据集·数据治理·数据质量·合规·ai治理
大大大大晴天️5 天前
元数据目录到数据资产运营:让好数据被看见、被复用、被持续经营
大数据·数据治理
森山冶仁7 天前
向量索引也要治理:RAG 系统里“原始数据已作废、向量仍可检索”怎么解
数据治理·向量数据库·数据质量·元数据·rag