ad1happy2go commented on issue #9870:
URL: https://github.com/apache/hudi/issues/9870#issuecomment-1764889217

   Simplified version of Reproducible Code - 
   
   ```
   COW_TABLE_NAME="table_duplicates"
   PARTITION_FIELD = "year,month"
   PRECOMBINE_FIELD = "timestamp"
   COW_TABLE_LOCATION="file:///tmp/issue_9870_" + str(uuid.uuid4())
   
   hudi_options_opt = {
       "hoodie.table.name": COW_TABLE_NAME,
       "hoodie.table.type": "COPY_ON_WRITE",
       "hoodie.index.type": "BLOOM",
       "hoodie.datasource.write.recordkey.field": "id",
       "hoodie.datasource.write.partitionpath.field": PARTITION_FIELD,
       "hoodie.datasource.write.precombine.field": PRECOMBINE_FIELD,
       "hoodie.datasource.write.hive_style_partitioning": "true",
       "hoodie.metadata.enable": "true",
       "hoodie.bloom.index.use.metadata": "true",
       "hoodie.metadata.index.column.stats.enable": "true",
       "hoodie.parquet.small.file.limit": -1
   }
   
   COW_TABLE_LOCATION="file:///tmp/issue_9870_" + str(uuid.uuid4())
   
   inputDF = spark.createDataFrame(
       [
           ('1', "1", '1',2020,1),
           ('2', "1", '1',2020,1),
           ('3', "1", '1',2020,1)
       ],
       ["id", "value", "timestamp","year","month"]
   )
   
   (inputDF.write.format("org.apache.hudi")
    .option("hoodie.datasource.write.operation", "upsert")
    .options(**hudi_options_opt)
    .mode("append")
    .save(COW_TABLE_LOCATION))
   
   upsertDF = spark.createDataFrame(
       [
           ('3', "2", '1',2020,1)
       ],
       ["id", "value", "timestamp","year","month"]
   )
   
   (upsertDF.write.format("org.apache.hudi")
    .option("hoodie.datasource.write.operation", "upsert")
    .options(**hudi_options_opt)
    .mode("append")
    .save(COW_TABLE_LOCATION))
   
   
spark.read.format('org.apache.hudi').load(COW_TABLE_LOCATION).groupBy("year","month","_hoodie_record_key").count().orderBy(desc("count")).show(100,
 False)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to