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

相关推荐
递归尽头是星辰15 小时前
大数据架构体系通识:存储、架构与数仓分层全解析
lambda·湖仓一体·大数据架构·kappa·数据仓库分层
数幄科技3 天前
电力装备制造业智能化转型】【数据基础设施篇】【5】数据采集 ETL 的可靠性设计
大数据·人工智能·算法·数据治理·数幄科技
大大大大晴天️3 天前
Hudi文件布局:COW与MOR表案例解析
大数据·hudi
大大大大晴天️5 天前
Hudi技术内幕:深入理解Hudi文件布局
大数据·hudi
千桐科技5 天前
qData 数据中台 2.0 智能化时代:从“汇集数据”到“创造智能”|六大升级深度解析
数据治理·数据管理·数据中台·qdata
袋鼠云数栈6 天前
从前端到基础设施,ACOS 如何打通企业全链路可观测
运维·前端·人工智能·数据治理·数据智能
袋鼠云数栈6 天前
数栈 V7.0 多模态数据智能平台:打造 AI-Ready 的企业数据底座
大数据·数据结构·数据库·人工智能·数据治理·多模态
wilbertzhou15 天前
联邦治理,不止是原则:数据网格落地的架构设计与组织博弈
数据治理·企业架构·数据网格·联邦治理·华为实践
想ai抽15 天前
AIAgent友好的数据治理框架-Apache Gravitino技术调研报告
ai·数据治理·gravitino
DataX_ruby8215 天前
企业常用的数据中台是哪些?
大数据·人工智能·数据治理·数据中台