You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2022/08/03 06:16:12 UTC
[GitHub] [hudi] boneanxs commented on a diff in pull request #6141: [HUDI-3189] Fallback to full table scan with incremental query when files are cleaned up or achived for MOR table
boneanxs commented on code in PR #6141:
URL: https://github.com/apache/hudi/pull/6141#discussion_r936274199
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/MergeOnReadIncrementalRelation.scala:
##########
@@ -124,14 +128,48 @@ trait HoodieIncrementalRelationTrait extends HoodieBaseRelation {
// Validate this Incremental implementation is properly configured
validate()
- protected lazy val includedCommits: immutable.Seq[HoodieInstant] = timeline.getInstants.iterator().asScala.toList
+ protected def startTimestamp: String = optParams(DataSourceReadOptions.BEGIN_INSTANTTIME.key)
+ protected def endTimestamp: String = optParams.getOrElse(DataSourceReadOptions.END_INSTANTTIME.key, super.timeline.lastInstant().get.getTimestamp)
+
+ protected def startOutOfRange: Boolean = super.timeline.isBeforeTimelineStarts(startTimestamp)
+ protected def endOutOfRange: Boolean = super.timeline.isBeforeTimelineStarts(endTimestamp)
+
+ // Fallback to full table scan if any of the following conditions matches:
+ // 1. the start commit is archived
+ // 2. the end commit is archived
+ // 3. there are files in metadata be deleted
+ protected lazy val fullTableScan: Boolean = {
+ val fallbackToFullTableScan = optParams.getOrElse(DataSourceReadOptions.INCREMENTAL_FALLBACK_TO_FULL_TABLE_SCAN_FOR_NON_EXISTING_FILES.key,
+ DataSourceReadOptions.INCREMENTAL_FALLBACK_TO_FULL_TABLE_SCAN_FOR_NON_EXISTING_FILES.defaultValue).toBoolean
+
+ fallbackToFullTableScan && (startOutOfRange || endOutOfRange || affectedFilesInCommits.exists(fileStatus => !metaClient.getFs.exists(fileStatus.getPath)))
+ }
+
+ protected lazy val includedCommits: immutable.Seq[HoodieInstant] = {
+ if (!endOutOfRange) {
+ // If endTimestamp commit is not archived, will filter instants
+ // before endTimestamp.
+ super.timeline.findInstantsInRange(startTimestamp, endTimestamp).getInstants.iterator().asScala.toList
+ } else {
+ super.timeline.getInstants.iterator().asScala.toList
+ }
Review Comment:
Yea, there could be a situation that startInstant is not archived, while endInstant is archived, should return empty commits
--
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-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org