当前位置: 首页 > news >正文

【Hudi-SQL DDL创建表语法】

CREATE TABLE

命令功能

CREATE TABLE命令通过指定带有表属性的字段列表来创建Hudi Table。

命令格式

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内部表

create table if not exists hudi_table0 (
id int,
name string,
price double
)  using hudi
options (
type = 'cow',
primaryKey = 'id'
);

– 创建一个mor外部表

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'
);

•创建分区表

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外表相同

create table h_p1
using hudi
options (
primaryKey = 'id',
preCombineField = 'ts'
)
partitioned by (dt)
location '/path/to/hudi';

•创建表指定表属性

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

http://www.dtcms.com/a/50057.html

相关文章:

  • 多视图几何--1关于变换-1.0写在前面的话
  • 【多模态目标检测】【AAAI 2025】FD2-Net
  • DeepSeek 助力 Vue3 开发:打造丝滑的表格(Table)示例1:基础表格
  • kotlin高级用法总结
  • ArcGIS Pro 经纬网添加全解析:从布局到样式优化
  • Adobe Firefly 技术浅析(一)
  • hive on tez如何设置写hdfs的数据文件为gz压缩
  • Python库之PyAutoGUI使用操作文本文件
  • e2studio开发RA4M2(15)----配置RTC时钟及显示时间
  • AutoSar架构学习笔记
  • 7、什么是死锁,如何避免死锁?【高频】
  • javaweb自用笔记:Vue
  • 计算机软考(二)-思维导图
  • linux如何在某个文件夹下查看所有文件(层级只到当前文件夹的两层)并找到‘XXXX’ 这个单词
  • 性能测试监控工具jmeter+grafana
  • 软考中级-数据库-3.4 数据结构-图
  • sql-labs靶场笔记
  • list
  • 一些相关知识
  • 队列的顺序结构——循环队列——入队
  • 【零基础到精通Java合集】第十一集:List集合框架与泛型
  • 【练习】【链表】力扣热题100 2. 两数相加
  • 鸿蒙开发中,数据持久化之Transaction(事务)的概念及应用
  • C语言基础要素(010):复合赋值
  • Android 14 - HDMI_CEC架构分析
  • Go语言学习笔记(六)——标准库
  • 量子算法:英译名、概念、历史、现状与展望?
  • SparkStreaming之04:调优
  • WPF高级 | WPF 应用程序部署与发布:确保顺利交付到用户手中
  • 深入 PipeWire