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

相关推荐
千桐科技2 天前
原子指标计算实现方案详解 | qData 数据中台商业版 · 指标平台
数据治理·指标平台·大数据平台·数据中台·指标管理·qdata·原子指标
千桐科技6 天前
稳定性增强、界面焕新:qData 数据中台开源版发布最新优化版本
开源软件·数据治理·大数据平台·数据中台·qdata·千数平台·千桐科技
zandy10119 天前
从“工具拼凑”到“平台一体”:8款数据治理工具测评,瓴羊Dataphin全链路平台重塑治理范式
大数据·数据治理·数据治理工具
wasp52016 天前
Hudi 元数据管理分析
java·大数据·linux·hudi·数据湖·数据湖仓
庄小焱17 天前
大数据治理域——数据资产管理示例
大数据·数据治理·大数据治理·数据治理实践
wasp52019 天前
Apache Hudi 项目总体分析
数据挖掘·apache·hudi·数据湖仓
熊猫钓鱼>_>24 天前
数据处理的艺术:从Kafka到实时流处理平台的技术深度剖析
分布式·flink·kafka·数据治理·状态管理·管道·数据工程师
智能化咨询1 个月前
(60页PPT)数据治理与数据安全防护方案(附下载方式)
数据治理
isNotNullX1 个月前
怎么用数据仓库来进行数据治理?
大数据·数据库·数据仓库·数据治理