在某些情况下,HUDI似乎没有破坏记录。下面是我们使用的配置。我们通过customer_id对数据进行分区,因此我们的期望是HUDI将在分区内执行唯一性,即每个customer_id文件夹。尽管我们注意到一些customer_id文件夹中有两个parquet文件,但是当我们查询这些分区中的数据时,我们注意到在同一个customer_id中存在重复的unique_user_id。对于两个重复的记录,_hoodie_record_key是相同的,但是_hoodie_file_name是不同的,这使我怀疑hudi不是在customer_id文件夹中,而是在这些单独的parquet文件中执行唯一性。有人能解释一下这种行为吗?
op: "INSERT"
target-base-path: "s3_path"
target-table: "some_table_name"
source-ordering-field: "created_at"
transformer-class: "org.apache.hudi.utilities.transform.SqlQueryBasedTransformer"
filter-dupes: ""
hoodie_conf:
# source table base path
hoodie.deltastreamer.source.dfs.root: "s3_path"
# record key, partition paths and keygenerator
hoodie.datasource.write.recordkey.field: "user_id,customer_id"
hoodie.datasource.write.partitionpath.field: "customer_id"
hoodie.datasource.write.keygenerator.class:
"org.apache.hudi.keygen.ComplexKeyGenerator"
# hive sync properties
hoodie.datasource.hive_sync.enable: true
hoodie.datasource.hive_sync.table: "table_name"
hoodie.datasource.hive_sync.database: "database_name"
hoodie.datasource.hive_sync.partition_fields: "customer_id"
hoodie.datasource.hive_sync.partition_extractor_class:
"org.apache.hudi.hive.MultiPartKeysValueExtractor"
hoodie.datasource.write.hive_style_partitioning: true
# sql transformer
hoodie.deltastreamer.transformer.sql: "SELECT user_id, customer_id, updated_at as
created_at FROM <SRC> a"
# since there is no dt partition, the following config from default has to be
overridden
hoodie.deltastreamer.source.dfs.datepartitioned.selector.depth: 0发布于 2022-09-03 19:11:01
默认情况下,您有hoodie.merge.allow.duplicate.on.inserts=false,它确保每个插入文件的唯一性,但不确保整个分区中的唯一性。
如果要在分区中强制执行唯一性,则需要使用hoodie.datasource.write.precombine.field (例如日期)选择预组合字段,hudi将使用该字段来决定它应该保存的数据的哪个版本,旧的还是新的。
字段在实际写入之前在preCombining中使用。当两个记录具有相同的键值时,我们将为预组合字段选择一个值最大的记录,由Object.compareTo(.)
确定
https://stackoverflow.com/questions/72024490
复制相似问题