nsivabalan commented on issue #5565:
URL: https://github.com/apache/hudi/issues/5565#issuecomment-1125513315

   here is the forEachBatch that I have come across from some other community 
user 
   ```
   
   
     val query = df.
     writeStream.
     queryName("demo").
     foreachBatch { (batchDF: org.apache.spark.sql.DataFrame, _: Long) => { 
           batchDF.persist() 
                println(LocalDateTime.now() + " start writing cow table") 
                batchDF.write.format("org.apache.hudi").
                option(TABLE_TYPE.key, "COPY_ON_WRITE").
                option(PRECOMBINE_FIELD.key, "kafka_timestamp").
                option(RECORDKEY_FIELD.key, "kafka_partition_offset").
                option(PARTITIONPATH_FIELD.key, "partition_date").
                option(HIVE_SYNC_ENABLED.key, false).
                option(HIVE_STYLE_PARTITIONING.key, true).
                option(FAIL_ON_TIMELINE_ARCHIVING_ENABLE.key, false).
                option(STREAMING_IGNORE_FAILED_BATCH.key, false).
                option(STREAMING_RETRY_CNT.key, 0).
                option("hoodie.table.name", "copy_on_write_table").
                
option("hoodie.clustering.plan.strategy.target.file.max.bytes","10485760").
                
option("hoodie.clustering.plan.strategy.small.file.limit","50000").
                
option("hoodie.clustering.plan.strategy.sort.columns","partition_date,kafka_partition_offset").
                option("hoodie.clustering.async.max.commits","2").
                option("hoodie.datasource.clustering.async.enable","true").
                option("hoodie.clustering.async.enabled","true").
                
option("hoodie.clustering.updates.strategy","org.apache.hudi.client.clustering.update.strategy.SparkAllowUpdateStrategy").
                mode(Append).
                save("/tmp/hudi_streaming_kafka/COPY_ON_WRITE")
                println(LocalDateTime.now() + " finish")
           batchDF.unpersist()
           }
         }.option("checkpointLocation", 
"/tmp/hudi_streaming_kafka/checkpoint/").start()
   
   ```
   
   this uses spark-datasource writes and not using streaming sink to write to 
hudi. 
   


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