leoyy0316 opened a new issue, #5932:
URL: https://github.com/apache/hudi/issues/5932
can not delete data when use spark scala code
1.use sparksql to create table
create table temp_db.hudi_delete_leo (
id int,
name string,
ts bigint
) using hudi
tblproperties (
type = 'mor',
primaryKey = 'id',
preCombineField = 'ts'
);
2.insert data to table
insert into temp_db.hudi_delete_leo select 1, 'a1', 1000;
insert into temp_db.hudi_mor_tbl_ts_delete select 2, 'a2',1000;
3.delete data use spark scal code
val spark = SparkSession
.builder
.appName("delete_init_leo")
.enableHiveSupport()
.getOrCreate()
val df = spark.sql("select * from temp_db.hudi_mor_tbl_ts_delete limit
1")
// spark.sql("delete from temp_db.hudi_mor_tbl_ts_delete where id = 1")
// spark.sql("select * from temp_db.hudi_mor_tbl_ts_delete").count()
df.write.format("org.apache.hudi")
// .option(DataSourceWriteOptions.HIVE_DATABASE.key(), "temp_db")
.option("hoodie.datasource.write.operation",
WriteOperationType.DELETE.value())
// .option(DataSourceWriteOptions.HIVE_SYNC_ENABLED.key(), "true")
// .option(DataSourceWriteOptions.HIVE_URL.key(),
"jdbc:hive2://10.88.132.76:10500")
// .option(DataSourceWriteOptions.HIVE_USER.key(), "itleoc")
// .option(DataSourceWriteOptions.HIVE_PASS.key(), "itleoc")
// .option(DataSourceWriteOptions.SQL_INSERT_MODE.key(), "non-strict")
.option(HoodieWriteConfig.TBL_NAME.key(), "hudi_mor_tbl_ts_delete")
.option(DataSourceWriteOptions.RECORDKEY_FIELD.key(), "id")
.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("/xxxxx/hive/temp_db.db/hudi_mor_tbl_ts_delete")
but if i use "delete from temp_db.hudi_mor_tbl_ts_delete where id = 1" can
delete data correctly
--
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]