Skip to content

Commit

Permalink
[fix] Create FileStoreTable directly from FileStoreTableFactory, inst…
Browse files Browse the repository at this point in the history
…ead of from catalog
  • Loading branch information
tsreaper committed Aug 5, 2024
1 parent 66f1eb1 commit ded168e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.paimon.schema.SchemaManager;
import org.apache.paimon.schema.TableSchema;
import org.apache.paimon.table.FileStoreTable;
import org.apache.paimon.table.FileStoreTableFactory;
import org.apache.paimon.table.TableType;
import org.apache.paimon.types.DataField;
import org.apache.paimon.types.DataTypes;
Expand Down Expand Up @@ -338,14 +339,15 @@ private boolean partitionExistsInOtherBranches(
continue;
}

Optional<TableSchema> branchSchema =
tableSchemaInFileSystem(mainTable.location(), branchName);
if (!branchSchema.isPresent()) {
continue;
}

FileStoreTable table =
(FileStoreTable)
getTable(
new Identifier(
identifier.getDatabaseName(),
identifier.getTableName(),
branchName,
null));
FileStoreTableFactory.create(
mainTable.fileIO(), mainTable.location(), branchSchema.get());
if (!table.newScan().withPartitionFilter(partitionSpec).listPartitions().isEmpty()) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,16 @@ public void testFlinkCreateBranchAndHiveRead() throws Exception {

@Test
public void testDropPartitionFromBranch() throws Exception {
testDropPartitionFromBranchImpl();
}

@Test
@LocationInProperties
public void testDropPartitionFromBranchLocationInProperties() throws Exception {
testDropPartitionFromBranchImpl();
}

private void testDropPartitionFromBranchImpl() throws Exception {
tEnv.executeSql(
"CREATE TABLE t ( pt INT, v STRING ) PARTITIONED BY (pt) "
+ "WITH ( 'file.format' = 'avro', 'metastore.partitioned-table' = 'true' )")
Expand Down

0 comments on commit ded168e

Please sign in to comment.