Hudi学习笔记(1)

发布时间 2023-05-06 12:51:03作者: -见

使用注意

  • 从 0.10.0 版本开始,primaryKey 为必须的,不再支持没有主键的表。

  • primaryKey、primaryKey 和 type 均大小写敏感。

  • 对于 MOR 类型的表,preCombineField 为必须的。

  • 当设置 primaryKey、primaryKey 或 type 等 hudi 配置时,tblproperties 优先于 options 。

  • 使用 Spark SQL 创建 hudi 表时,默认设置:hoodie.datasource.write.hive_style_partitioning=true 。

Hudi 0.13.0 新功能

2023/2/22 日发布(https://hudi.apache.org/releases/release-0.13.0/)。

  • PartialUpdateAvroPayload

开箱即用支持部分负载更新。

  • 一致性哈希索引(Consistent Hashing Index)

set hoodie.index.bucket.engine='CONSISTENT_HASHING'

  • 多客户端写入的早期冲突检测(OCC)

set hoodie.write.concurrency.early.conflict.detection.enable='true'

  • 支持 支持 Flink 1.16

  • 支持 Pulsar 数据源

  • 更新 CDC(Change-Data-Capture)

注意 CDC 仍是实验性功能,仅支持 COW 表,CDC 查询尚不支持 MOR 表。

  • 新增元数据管理服务 Metaserver

hoodie.metaserver.enabled=true
hoodie.metaserver.uris=thrift://:9090

注意目前为实验性功能。

常用表属性

  • hoodie.datasource.write.hive_style_partitioning

是否使用 hive 风格的表分区。使用 Spark SQL 创建的 hudi 表默认为 true,使用 Flink SQL 创建的 hudi 表默认为 false 。

  • hoodie.sql.insert.mode

设置数据插入模式,有三种取值(默认为 upsert):

  • upsert

更新插入模式,是否更新依赖 tblproperties 的 preCombineField 指定的值(一般为 BIGINT 类型的时间戳值),亦即 hoodie.datasource.write.precombine.field 的值。

  • strict

严格模式,为纯 insert 模式,但如果相同 tblproperties 的 primaryKey 已经存在,亦即 hoodie.datasource.write.recordkey.field 指定的已存在,则不执行插入,否则插入。

  • non-strict

非严格模式,也为纯 insert 模式,不会关系 primaryKey 是否已经存在,允许重复。

  • hoodie.datasource.write.operation

设置写操作,有三种取值(默认为 upsert):

  • upsert

更新插入。

  • insert

普通插入。

  • bulkinsert

批量插入。如果设置为 bulkinsert,还得同时将 hoodie.sql.bulk.insert.enable 值设置为 true,注意 hoodie.sql.bulk.insert.enable 值默认为 false 。

  • hoodie.index.type

设置索引类型。对 spark 引擎默认为 SIMPLE,对 flink 引擎默认为 INMEMORY。可选取值有:BLOOM | GLOBAL_BLOOM |SIMPLE | GLOBAL_SIMPLE | INMEMORY | HBASE | BUCKET。

  • hoodie.bucket.index.num.buckets

设置每个分区的桶数,注意表创建后不能修改,仅当 hoodie.index.type 值为 BUCKET 时有效。

  • hoodie.index.bucket.engine

设置桶索引引擎类型,默认为 SIMPLE,可选的包括:SIMPLE | CONSISTENT_HASHING。SIMPLE 为固定个数的桶,CONSISTENT_HASHING 支持动态调整桶数。

  • hoodie.simple.index.parallelism

仅适用 hoodie.index.type 为 SIMPLE。用于指定索引查询并行度,默认为 100,同 Spark Shuffle 相关。

  • hoodie.write.concurrency.early.conflict.detection.enable

版本:0.13.0(实验性的)

是否启用控制乐观并发控制 OCC(Optimistic Concurrency Control),默认为 false,即关闭 OCC,这时不能有多写入者。