[HUDI-3457] Refactored Spark DataSource Relations to avoid code duplication (#4877)
Refactoring Spark DataSource Relations to avoid code duplication. Following Relations were in scope: - BaseFileOnlyViewRelation - MergeOnReadSnapshotRelaation - MergeOnReadIncrementalRelation
This commit is contained in:
@@ -198,7 +198,7 @@ public abstract class BaseHoodieTableFileIndex {
|
||||
// that is under the pending compaction process, new log-file will bear the compaction's instant (on the
|
||||
// timeline) in its name, as opposed to the base-file's commit instant. To make sure we're not filtering
|
||||
// such log-file we have to _always_ include pending compaction instants into consideration
|
||||
// TODO(HUDI-3302) re-evaluate whether we should not filter any commits in here
|
||||
// TODO(HUDI-3302) re-evaluate whether we should filter any commits in here
|
||||
HoodieTimeline timeline = metaClient.getCommitsAndCompactionTimeline();
|
||||
if (shouldIncludePendingCommits) {
|
||||
return timeline;
|
||||
|
||||
@@ -509,19 +509,16 @@ public class TableSchemaResolver {
|
||||
* @return
|
||||
*/
|
||||
public static MessageType readSchemaFromLogFile(FileSystem fs, Path path) throws IOException {
|
||||
Reader reader = HoodieLogFormat.newReader(fs, new HoodieLogFile(path), null);
|
||||
HoodieDataBlock lastBlock = null;
|
||||
while (reader.hasNext()) {
|
||||
HoodieLogBlock block = reader.next();
|
||||
if (block instanceof HoodieDataBlock) {
|
||||
lastBlock = (HoodieDataBlock) block;
|
||||
try (Reader reader = HoodieLogFormat.newReader(fs, new HoodieLogFile(path), null)) {
|
||||
HoodieDataBlock lastBlock = null;
|
||||
while (reader.hasNext()) {
|
||||
HoodieLogBlock block = reader.next();
|
||||
if (block instanceof HoodieDataBlock) {
|
||||
lastBlock = (HoodieDataBlock) block;
|
||||
}
|
||||
}
|
||||
return lastBlock != null ? new AvroSchemaConverter().convert(lastBlock.getSchema()) : null;
|
||||
}
|
||||
reader.close();
|
||||
if (lastBlock != null) {
|
||||
return new AvroSchemaConverter().convert(lastBlock.getSchema());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isHasOperationField() {
|
||||
|
||||
Reference in New Issue
Block a user