danny0405 commented on code in PR #6141:
URL: https://github.com/apache/hudi/pull/6141#discussion_r935199186
##########
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:
But we should also take the start instant into consideration.
--
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]