waywtdcc commented on code in PR #10390:
URL: https://github.com/apache/hudi/pull/10390#discussion_r1434666345
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/command/TruncateHoodieTableCommand.scala:
##########
@@ -68,7 +71,12 @@ case class TruncateHoodieTableCommand(
val targetPath = new Path(basePath)
val engineContext = new
HoodieSparkEngineContext(sparkSession.sparkContext)
val fs = FSUtils.getFs(basePath,
sparkSession.sparkContext.hadoopConfiguration)
+ val hoodieWriteConfig =
HoodieWriteConfig.newBuilder().withPath(basePath).withProps(properties).withEngineType(EngineType.SPARK)
+ .build()
+ val transactionManager = new TransactionManager(hoodieWriteConfig, fs)
+
transactionManager.beginTransaction(org.apache.hudi.common.util.Option.empty(),
org.apache.hudi.common.util.Option.empty())
FSUtils.deleteDir(engineContext, fs, targetPath,
sparkSession.sparkContext.defaultParallelism)
+
transactionManager.endTransaction(org.apache.hudi.common.util.Option.empty())
Review Comment:
When the truncate table and the insert statement are executed at the same
time, the table data may be damaged.
--
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]