[SUPPORT] Flink Table Sql write hudi , data duplication in same partition
- Dominant language
- Java
- Stars
- 6.2k
- Forks
- 2.5k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 111
Description
**_Tips before filing an issue_**
- Have you gone through our [FAQs](https://hudi.apache.org/learn/faq/)?
- Join the mailing list to engage in conversations and get faster support at dev-subscribe@hudi.apache.org.
- If you have triaged this as a bug, then file an [issue](https://issues.apache.org/jira/projects/HUDI/issues) directly.
**Describe the problem you faced**
A clear and concise description of the problem.
**To Reproduce**
Steps to reproduce the behavior:
flink table sql will query a source table of kafka, partition it into two tables according to two different time fields, the data of the first table (rt table, ro table) is normal, and the data of the second table (rt table,ro table) is duplicate in same partition (This job is run in a flink job),
If this job is split into two flink job, the data of the two tables (rt table, ro table) is normal
`querySql:
CREATE TABLE kafka_source(
id VARCHAR(20),
date1 STRING,
date2 STRING,
ts TIMESTAMP(3) METADATA FROM 'timestamp'
)
PARTITIONED BY (date1)
WITH (
'connector' = 'kafka'
,'topic-pattern' = 'xx[a-z]'
,'scan.startup.mode' = 'earliest-offset'
,'value.format' = 'json'
,'json.ignore-parse-errors' = 'true'
,'properties.fetch.message.max.bytes' = '10485760'
,'properties.socket.receive.buffer.bytes' = '1048576'
,'properties.request.timeout.ms' = '60000'
,'properties.group.id' = 'xx'
,'properties.bootstrap.servers'='xx'
);
sinkSql1:
CREATE TABLE t1(
id VARCHAR(20) PRIMARY KEY NOT ENFORCED,
date1 STRING,
date2 STRING,
ts TIMESTAMP(3)
)
PARTITIONED BY (date1)
WITH (
'hoodie.table.type' = 'COPY_ON_WRITE'
,'hoodie.datasource.write.recordkey.field' = 'id'
,'hoodie.datasource.write.precombine.field' = 'ts'
,'hoodie.datasource.write.partitionpath.field' = 'date1'
,'hoodie.parquet.compression.codec'= 'snappy'
,'connector' = 'hudi'
,'path' = '$hdfsPath'
,'hive_sync.partition_fields' = 'date1'
,'hive_sync.metastore.uris' = '$thrift://xxx'
,'hive_sync.db' = '$hiveDatabaseName'
,'hive_sync.table' = '$hiveTableName'
,'hive_sync.enable' = 'true'
,'hive_sync.use_jdbc' = 'false'
,'hive_sync.mode' = 'hms'
,'write.tasks'='20'
,'compaction.async.enabled'='true'
,'compaction.trigger.strategy'='num_commits'
,'compaction.delta_commits'='2'
,'write.precombine.field' = 'ts'
,'hoodie.datasource.write.partitionpath.field' = 'date1'
,'hive_sync.partition_extractor_class' = 'org.apache.hudi.hive.MultiPartKeysValueExtractor'
);
sinkSql2:
CREATE TABLE t2(
id VARCHAR(20) PRIMARY KEY NOT ENFORCED,
date1 STRING,
date2 STRING,
ts TIMESTAMP(3)
)
PARTITIONED BY (date2)
WITH (
'hoodie.table.type' = 'COPY_ON_WRITE'
,'hoodie.datasource.write.recordkey.field' = 'id'
,'hoodie.datasource.write.precombine.field' = 'ts'
,'hoodie.datasource.write.partitionpath.field' = 'date2'
,'hoodie.parquet.compression.codec'= 'snappy'
,'connector' = 'hudi'
,'path' = '$hdfsPath'
,'hive_sync.partition_fields' = 'date2'
,'hive_sync.metastore.uris' = '$thrift://xxx'
,'hive_sync.db' = '$hiveDatabaseName'
,'hive_sync.table' = '$hiveTableName'
,'hive_sync.enable' = 'true'
,'hive_sync.use_jdbc' = 'false'
,'hive_sync.mode' = 'hms'
,'write.tasks'='20'
,'compaction.async.enabled'='true'
,'compaction.trigger.strategy'='num_commits'
,'compaction.delta_commits'='2'
,'write.precombine.field' = 'ts'
,'hoodie.datasource.write.partitionpath.field' = 'date2'
,'hive_sync.partition_extractor_class' = 'org.apache.hudi.hive.MultiPartKeysValueExtractor'
);
insertSql1:
'insert into t1 select * from source_table';
insertSql2:
'insert into t2 select * from source_table';
CASE1:
one Flink Job
TableEnv.executeSql(querySql)
TableEnv.executeSql(sinkSql1)
TableEnv.executeSql(sinkSql2)
TableEnv.createStatementSet().addInsertSql(insertSql1).addInsertSql(insertSql2).execute()
CASE2:
two Flink Job(kafka consumer group id is changed)
Flink Job1
TableEnv.executeSql(querySql)
TableEnv.executeSql(sinkSql1)
TableEnv.executeSql(insertSql1)
Flink Job2
TableEnv.executeSql(querySql)
TableEnv.executeSql(sinkSql2)
TableEnv.executeSql(insertSql2)
As shown above
when query use hive;
case1 table t2 data in same partition is duplicate , table t1 data is normal
case2 table t1, table t2 data is normal`
**Expected behavior**
A clear and concise description of what you expected to happen.
**Environment Description**
* Hudi version :1.11.1 and 1.11.0
* Spark version :
* Hive version :2.11cdh
* Hadoop version :3.0.0cdh
* Storage (HDFS/S3/GCS..) :hdfs
* Running on Docker? (yes/no) :no
**Additional context**
Add any other context about the problem here.
**Stacktrace**
```Add the stacktrace of the error.```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.