leoyy0316 commented on issue #5932:
URL: https://github.com/apache/hudi/issues/5932#issuecomment-1163872024

   @nsivabalan @YannByron 
   i have try another way
   
   import org.apache.hudi.DataSourceWriteOptions
   import org.apache.hudi.config.{HoodieStorageConfig, HoodieWriteConfig}
   import org.apache.spark.sql.{SaveMode, SparkSession}
   
   val df = spark.sql("select *, concat(order_no,order_type) as id ,0 as ts  
from ods_us.ods_cis_dbo_order_header limit 5")
   
   import org.apache.spark.sql.types.{BooleanType, StructField, StructType}
   val df1 = df.withColumn("_hoodie_is_deleted", lit(false).cast(BooleanType))
   
   
df1.write.format("org.apache.hudi").option(DataSourceWriteOptions.RECORDKEY_FIELD.key(),
 "id").option(DataSourceWriteOptions.PRECOMBINE_FIELD.key(), 
"ts").option(DataSourceWriteOptions.HIVE_DATABASE.key(), 
"temp_db").option(DataSourceWriteOptions.HIVE_TABLE.key(), 
"scala_ods_cis_dbo_order_header_leo_1").option(DataSourceWriteOptions.HIVE_SYNC_ENABLED.key(),
 "true").option(DataSourceWriteOptions.HIVE_URL.key(), 
"jdbc:hive2://xxx:xxx").option(DataSourceWriteOptions.HIVE_USER.key(), 
"xxx").option(DataSourceWriteOptions.HIVE_PASS.key(), 
"xxx").option(DataSourceWriteOptions.SQL_INSERT_MODE.key(), 
"non-strict").option(HoodieWriteConfig.TBL_NAME.key(), 
"scala_ods_cis_dbo_order_header_leo_1").option("hoodie.bulkinsert.shuffle.parallelism",
 2).option(DataSourceWriteOptions.OPERATION.key(), 
DataSourceWriteOptions.BULK_INSERT_OPERATION_OPT_VAL).mode(SaveMode.Append).save("/user/xxx/testhudi/scala_ods_cis_dbo_order_header_leo_1")
   
   val df_delete = spark.sql("select * from 
temp_db.scala_ods_cis_dbo_order_header_leo_1 limit 1")
   
   val dff = df_delete.withColumn("_hoodie_is_deleted", 
lit(true).cast(BooleanType))
   
   
dff.write.format("org.apache.hudi").option(DataSourceWriteOptions.RECORDKEY_FIELD.key(),
 "id").option(DataSourceWriteOptions.HIVE_DATABASE.key(), 
"temp_db").option(DataSourceWriteOptions.HIVE_TABLE.key(), 
"scala_ods_cis_dbo_order_header_leo_1").option(DataSourceWriteOptions.HIVE_SYNC_ENABLED.key(),
 "true").option(DataSourceWriteOptions.HIVE_URL.key(), 
"jdbc:hive2://xxx:xxx").option(DataSourceWriteOptions.HIVE_USER.key(), 
"xxx").option(DataSourceWriteOptions.HIVE_PASS.key(), 
"xxx").option(DataSourceWriteOptions.PRECOMBINE_FIELD.key(), 
"ts").option("hoodie.insert.shuffle.parallelism", 
"2").option("hoodie.upsert.shuffle.parallelism", 
"2").option("hoodie.bulkinsert.shuffle.parallelism", 
"2").option("hoodie.delete.shuffle.parallelism", 
"2").mode(SaveMode.Append).save("/user/xxx/testhudi/scala_ods_cis_dbo_order_header_leo_1")


-- 
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: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to