Skip to content

Commit

Permalink
[core] Validate FileStoreTableFactory create fallback branch
Browse files Browse the repository at this point in the history
  • Loading branch information
JingsongLi committed Nov 1, 2024
1 parent 5e99066 commit 38fc717
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@

import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Optional;

import static org.apache.paimon.CoreOptions.PATH;
import static org.apache.paimon.utils.Preconditions.checkArgument;

/** Factory to create {@link FileStoreTable}. */
public class FileStoreTableFactory {
Expand Down Expand Up @@ -93,13 +95,17 @@ public static FileStoreTable create(
if (!StringUtils.isNullOrWhitespaceOnly(fallbackBranch)) {
Options branchOptions = new Options(dynamicOptions.toMap());
branchOptions.set(CoreOptions.BRANCH, fallbackBranch);
Optional<TableSchema> schema =
new SchemaManager(fileIO, tablePath, fallbackBranch).latest();
checkArgument(
schema.isPresent(),
"Cannot set '%s' = '%s' because the branch '%s' isn't existed.",
CoreOptions.SCAN_FALLBACK_BRANCH.key(),
fallbackBranch,
fallbackBranch);
FileStoreTable fallbackTable =
createWithoutFallbackBranch(
fileIO,
tablePath,
new SchemaManager(fileIO, tablePath, fallbackBranch).latest().get(),
branchOptions,
catalogEnvironment);
fileIO, tablePath, schema.get(), branchOptions, catalogEnvironment);
table = new FallbackReadFileStoreTable(table, fallbackTable);
}

Expand Down

0 comments on commit 38fc717

Please sign in to comment.