linliu-code commented on code in PR #12588:
URL: https://github.com/apache/hudi/pull/12588#discussion_r1907720422
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala:
##########
@@ -1165,3 +1163,54 @@ class HoodieSparkSqlWriterInternal {
.map(_.toLong).filter(SQLExecution.getQueryExecution(_) eq
newQueryExecution)
}
}
+
+object HoodieSparkSqlWriterInternal {
+ // Check if duplicates should be dropped.
+ def shouldDropDuplicatesForInserts(hoodieConfig: HoodieConfig): Boolean = {
+ hoodieConfig.contains(INSERT_DUP_POLICY) &&
+
hoodieConfig.getString(INSERT_DUP_POLICY).equalsIgnoreCase(DROP_INSERT_DUP_POLICY)
+ }
+
+ // Check if we should fail if duplicates are found.
+ def shouldFailWhenDuplicatesFound(hoodieConfig: HoodieConfig): Boolean = {
+ hoodieConfig.contains(INSERT_DUP_POLICY) &&
+
hoodieConfig.getString(INSERT_DUP_POLICY).equalsIgnoreCase(FAIL_INSERT_DUP_POLICY)
+ }
+
+ // Check if deduplication is required.
+ def isDeduplicationRequired(hoodieConfig: HoodieConfig): Boolean = {
+ hoodieConfig.getBoolean(INSERT_DROP_DUPS) ||
+ shouldFailWhenDuplicatesFound(hoodieConfig) ||
+ shouldDropDuplicatesForInserts(hoodieConfig)
+ }
+
+ // Check if deduplication is needed.
+ def isDeduplicationNeeded(operation: WriteOperationType): Boolean = {
Review Comment:
I take it from the master, LINE 510. I modified it to narrow down the impact
to only insert. Previously it could impact upsert also.
--
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]