Skip to content

Commit

Permalink
Fix create view failure (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
nk1506 committed Sep 12, 2024
1 parent 6818d35 commit 4c2a449
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,9 @@ private class BasePolarisCatalogViewBuilder extends BaseMetastoreViewCatalog.Bas

public BasePolarisCatalogViewBuilder(TableIdentifier identifier) {
super(identifier);
withProperties(
PropertyUtil.propertiesWithPrefix(
BasePolarisCatalog.this.properties(), "table-default."));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ private void cleanupCatalog(String catalogName) {
for (Row table : tables) {
onSpark("DROP TABLE " + namespace.getString(0) + "." + table.getString(1));
}
List<Row> views = onSpark("SHOW VIEWS IN " + namespace.getString(0)).collectAsList();
for (Row view : views) {
onSpark("DROP VIEW " + namespace.getString(0) + "." + view.getString(1));
}
onSpark("DROP NAMESPACE " + namespace.getString(0));
}
try (Response response =
Expand Down Expand Up @@ -351,6 +355,20 @@ public void testCreateAndUpdateExternalTable() {
assertThat(rowCount).isEqualTo(4);
}

@Test
public void testCreateView() {
long namespaceCount = onSpark("SHOW NAMESPACES").count();
assertThat(namespaceCount).isEqualTo(0L);

onSpark("CREATE NAMESPACE ns1");
onSpark("USE ns1");
onSpark("CREATE TABLE tb1 (col1 integer, col2 string)");
onSpark("INSERT INTO tb1 VALUES (1, 'a'), (2, 'b'), (3, 'c')");
onSpark("CREATE VIEW view1 AS SELECT * FROM tb1");
long recordCount = onSpark("SELECT * FROM view1").count();
assertThat(recordCount).isEqualTo(3);
}

private LoadTableResponse loadTable(String catalog, String namespace, String table) {
try (Response response =
EXT.client()
Expand Down

0 comments on commit 4c2a449

Please sign in to comment.