Skip to content

Commit

Permalink
Test setCurrentCatalog and setCurrentDatabase (unitycatalog#297)
Browse files Browse the repository at this point in the history
**Description of changes**

<!-- Please state what you've changed and how it might affect the users.
-->

Test setCurrentCatalog and setCurrentDatabase. Note that we identified a
Spark issue that needs a fix on Spark side to support `spark_catalog`
override in UC.
  • Loading branch information
amaliujia authored Jul 30, 2024
1 parent 9e6ac0e commit 95bca30
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,19 @@ public void testDropTable() throws ApiException, IOException {
session.stop();
}

@Test
public void testSetCurrentDB() throws ApiException {
createCommonResources();
SparkSession session = createSparkSessionWithCatalogs(SPARK_CATALOG, TestUtils.CATALOG_NAME);
session.catalog().setCurrentCatalog(TestUtils.CATALOG_NAME);
session.catalog().setCurrentDatabase(SCHEMA_NAME);
session.catalog().setCurrentCatalog(SPARK_CATALOG);
// TODO: We need to apply a fix on Spark side to use v2 session catalog handle
// `setCurrentDatabase` when the catalog name is `spark_catalog`.
// session.catalog().setCurrentDatabase(SCHEMA_NAME);
session.stop();
}

private String generateTableLocation(String catalogName, String tableName) throws IOException {
return new File(new File(dataDir, catalogName), tableName).getCanonicalPath();
}
Expand Down

0 comments on commit 95bca30

Please sign in to comment.