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

   @neeruks @rjmblc  Can you please try with later versions of Hudi. I see it 
is all working seemlesly even with both the settings.
   
   ```
   from pyspark.sql.types import *
   from pyspark.sql.functions import *
   import time
   from datetime import datetime
   from pyspark.sql import SparkSession
   from pyspark.sql import Row
   from datetime import date
   
   spark = SparkSession \
       .builder \
       .master("local[1]") \
       .config("spark.driver.memory", "8g") \
       .config("spark.jars.packages", 
"org.apache.hudi:hudi-spark3.2-bundle_2.12:0.13.0") \
       .config("spark.sql.extensions", 
"org.apache.spark.sql.hudi.HoodieSparkSessionExtension") \
       .config("spark.sql.catalog.spark_catalog", 
"org.apache.spark.sql.hudi.catalog.HoodieCatalog") \
       .config("spark.serializer", 
"org.apache.spark.serializer.KryoSerializer") \
       .getOrCreate()
   
   common_config={
       "hoodie.datasource.write.table.type": "MERGE_ON_READ",
       "hoodie.datasource.write.recordkey.field": "id",
       "hoodie.datasource.write.precombine.field": "timestamp",
       "hoodie.datasource.write.partitionpath.field": "id",
       'hoodie.table.name': 'issue_8625',
       "hoodie.datasource.write.payload.class": 
"org.apache.hudi.common.model.OverwriteWithLatestAvroPayload"
   }
   # Define the schema
   schema = StructType([
       StructField("id", IntegerType(), True),
       StructField("b", IntegerType(), True),
       StructField("c", StringType(), True),
       StructField("d", DateType(), True),
       StructField("timestamp", TimestampType(), True),
       StructField("f", StringType(), True)
   ])
   
   df = spark.createDataFrame([
       Row(id=1, b=2, c='string1', d=date(2000, 1, 1), 
timestamp=datetime.strptime("2000-01-01 12:00:00", '%Y-%m-%d %H:%M:%S'), f = 
"2000-01-01 12:00:00"),
       Row(id=2, b=3, c='string2', d=date(2000, 2, 1), 
timestamp=datetime.strptime("2000-01-01 12:00:00", '%Y-%m-%d %H:%M:%S'), f = 
"2000-01-01 12:21:20"),
       Row(id=4, b=5, c='string3', d=date(2000, 3, 1), 
timestamp=datetime.strptime("2000-01-01 12:00:00", '%Y-%m-%d %H:%M:%S'), f = 
"2000-01-03 12:00:00")
   ], schema)
   
   path = "file:///tmp/issue_6341_5"
   df.write.format("org.apache.hudi") \
       .options(**common_config) \
       .mode("append") \
       .save(path)
   
   spark.read.format("hudi").load(path).show()
   
   newdf = spark.createDataFrame([
       Row(id=1, b=16, c=None, d=None, timestamp=datetime.strptime("2000-01-01 
12:35:00", '%Y-%m-%d %H:%M:%S'), f=None)
   ], schema)
   
   newdf.write.format("org.apache.hudi") \
       .options(**common_config) \
       .option("hoodie.datasource.write.operation", "delete") \
       .option('hoodie.datasource.write.payload.class', 
'org.apache.hudi.common.model.EmptyHoodieRecordPayload') \
       .mode("append") \
       .save(path)
   
   spark.read.format("hudi").load(path).show()
   ```


-- 
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