Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HUDI-7102] Fix a bug for time travel queries on MOR tables #10102

Merged
Merged
Show file tree
Hide file tree
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 @@ -260,7 +260,7 @@ private void scanInternalV1(Option<KeySpec> keySpecOpt) {
&& !HoodieTimeline.compareTimestamps(logBlock.getLogBlockHeader().get(INSTANT_TIME), HoodieTimeline.LESSER_THAN_OR_EQUALS, this.latestInstantTime
)) {
// hit a block with instant time greater than should be processed, stop processing further
break;
continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey folks. do we need this fix for 0.14.x as well. or do we need only for 1.x?
in other words, should I cherry this for 0.14.1 upcoming relase?

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reader consumption upper threshold is introduced for unnecessary reading of log block, should we drop it? I don't think so, maybe you shoud just fix the threshold itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing the threshold? Do you mean increase the AS_OF timestamp given from the query?

Copy link
Contributor Author

@linliu-code linliu-code Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danny0405, after discussing with @yihua , the fix here is correct since the order of log blocks have been reversed and the "break" logic was for the old design where the blocks are in the order of time. CC:@yihua

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BaseHoodieLogRecordReader is used by the new file group reader only and this one uses HoodieLogFormatReverseReader which reads the log files in reverse order based on the input log file list. Right now for time travel queries, the file system view still returns more logs than required (e.g., bf, log_t1, log_t2, log_t3, log_t4, for time travel query with as of t2), so this change makes sure the processing does not stop unnecessarily before the file system view returns the exact files to process.

@linliu-code could you add this detail to the other ticket fixing the file system view APIs based on completion time, so we should revisit this part alongside the FSV fix?

if (logBlock.getBlockType() != CORRUPT_BLOCK && logBlock.getBlockType() != COMMAND_BLOCK) {
if (!completedInstantsTimeline.containsOrBeforeTimelineStarts(instantTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ object DefaultSource {
new IncrementalRelation(sqlContext, parameters, userSchema, metaClient)

case (MERGE_ON_READ, QUERY_TYPE_SNAPSHOT_OPT_VAL, false) =>
val isTimeTravelQuery = parameters.contains(TIME_TRAVEL_AS_OF_INSTANT.key())
if (fileFormatUtils.isDefined && !isTimeTravelQuery) {
if (fileFormatUtils.isDefined) {
new HoodieMergeOnReadSnapshotHadoopFsRelationFactory(
sqlContext, metaClient, parameters, userSchema, isBootstrap = false).build()
} else {
Expand Down
Loading