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

相关推荐
迈巴赫车主7 小时前
湖仓一体(Data Lakehouse)简介
大数据·数据仓库·数据湖·湖仓一体
胡耀超1 天前
从一次批量爬取到生产同步:问题变了,建设边界也要跟着变
爬虫·python·系统架构·数据治理·数据同步·接口设计·爬虫工程
DataX_ruby825 天前
DCMM 2.0 贯标评估全解读:数据中台如何支撑九大能力域(2026版)
大数据·运维·人工智能·数据治理·数据中台
龙石数据13 天前
MySQL 全量同步到 Hive 怎么做?三步配置教程
数据库·hive·mysql·数据治理·数据中台
数据库小学妹13 天前
数据库架构入门到进阶:单机、主从、分库分表到分布式的选型实战
数据仓库·分布式数据库·数据治理·数据库架构·架构设计·数据分层
wilbertzhou1 个月前
大语言模型时代的语义元数据:从静态资产目录到智能治理
人工智能·llm·大语言模型·数据治理·元数据管理·语义元数据
大大大大晴天️1 个月前
Hudi技术内幕:Write Operations 深度解析
大数据·hudi
DataX_ruby821 个月前
2026年数据中台厂商市场份额分析
大数据·人工智能·数据治理·数据中台
真上帝的左手1 个月前
19. 大数据-数据治理-体系建设全流程
大数据·数据治理
大大大大晴天️1 个月前
Hudi技术内幕:Query Types全解析
大数据·hudi