Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ case class HoodieFileIndex(spark: SparkSession,
*/
@transient private lazy val functionalIndex = new FunctionalIndexSupport(spark, metadataConfig, metaClient)

private var currentTimelineHash: String = null

override def rootPaths: Seq[Path] = getQueryPaths.asScala

/**
Expand Down Expand Up @@ -153,6 +155,13 @@ case class HoodieFileIndex(spark: SparkSession,
* @return list of PartitionDirectory containing partition to base files mapping
*/
override def listFiles(partitionFilters: Seq[Expression], dataFilters: Seq[Expression]): Seq[PartitionDirectory] = {
// Clear the old version's file index cache if there are new commits, to ensure the data from the new commits is visible.
if (currentTimelineHash == null || !currentTimelineHash.equals(metaClient.reloadActiveTimeline().getTimelineHash)) {
logInfo(s"Refreshing HoodieFileIndex for new instant ${metaClient.getActiveTimeline.lastInstant().get().toString}")
currentTimelineHash = metaClient.getActiveTimeline.getTimelineHash
refresh()
logInfo( "Refreshing HoodieFileIndex completed")
}
val prunedPartitionsAndFilteredFileSlices = filterFileSlices(dataFilters, partitionFilters).map {
case (partitionOpt, fileSlices) =>
if (shouldEmbedFileSlices) {
Expand Down