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

【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.kler.cn/a/573047.html

相关文章:

  • 01_NLP基础之文本处理的基本方法
  • 【Kubernets】K8S内部nginx访问Service资源原理说明
  • 【C语言】宏定义中X-Micro的使用
  • MySQL 数据库连接池爆满问题排查与解决
  • STM32---FreeRTOS临界段与任务调度器
  • 华为od机试-缓存需要最少金币数 /静态扫描(java)
  • 【C++设计模式】第四篇:建造者模式(Builder)
  • 机器学习-决策树详细解释
  • 算法进阶——枚举
  • 构建智能 SQL 查询代理agent,把整个查询过程模块化,既能自动判断使用哪些表,又能自动生成 SQL 语句,最终返回查询结果
  • 敏捷开发之自动化流水线
  • Ubuntu ollama 指定 gpu devices
  • 【VS2019】 .Net Core 3.1 无法打开项目文件
  • MagicArticulate: Make Your 3D Models Articulation-Ready 论文解读
  • SSE 和 WebSocket 的对比
  • 如何在Spring Boot中读取JAR包内resources目录下文件
  • 【封闭式】论文写作技巧--集中学习+集中写作
  • 高并发应用分层架构
  • 【MySQL】索引|作用|底层数据结构|常见问题
  • unity6 打包webgl注意事项