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

相关推荐
千桐科技9 小时前
qData 数据中台开源版 1.1.2 版本更新公告:新增 Apache Doris 数据源全面支持,稽查规则与转换组件持续完善
开源软件·数据治理·doris·数据集成·大数据平台·数据中台·qdata
喵手1 天前
Python爬虫实战:数据治理实战 - 基于规则与模糊匹配的店铺/公司名实体消歧(附CSV导出 + SQLite持久化存储)!
爬虫·python·数据治理·爬虫实战·零基础python爬虫教学·规则与模糊匹配·店铺公司名实体消岐
Aloudata1 天前
数据工程视角:指标平台选型深度对比(BI 指标中心 vs 传统 vs Headless vs 自动化平台)
数据分析·自动化·数据治理·指标平台·noetl
袋鼠云数栈1 天前
让多模态数据真正可用,AI 才能走出 Demo
大数据·人工智能·数据治理·多模态
Aloudata1 天前
数据工程成本优化:Aloudata CAN NoETL指标平台如何释放1/3+服务器资源
数据分析·自动化·数据治理·指标平台·noetl
Aloudata1 天前
金融数据治理新范式:如何用算子级血缘与主动元数据 10分 钟定位 EAST 报送异常?
金融·数据治理·元数据·noetl·数据血缘
亿信华辰软件2 天前
已经上了数据中台,还要做数据治理吗?
大数据·人工智能·数据治理
Aloudata2 天前
破解监管溯源难题:从表级血缘到算子级血缘的数据治理升级
数据库·数据挖掘·数据治理·元数据·数据血缘
百夜﹍悠ゼ3 天前
数据治理DataHub安装部署
大数据·数据治理
Aloudata5 天前
告别 90% 误报率:基于算子级血缘实现精准数据治理与变更影响分析
数据挖掘·数据治理·元数据·数据血缘