@Test
  public void otherCatalog() throws TException {
    String catName = "get_exists_tables_in_other_catalogs";
    Catalog cat = new CatalogBuilder()
        .setName(catName)
        .setLocation(MetaStoreTestUtils.getTestWarehouseDir(catName))
        .build();
    client.createCatalog(cat);

    String dbName = "db_in_other_catalog";
    // For this one don't specify a location to make sure it gets put in the catalog directory
    Database db = new DatabaseBuilder()
        .setName(dbName)
        .setCatalogName(catName)
        .create(client, metaStore.getConf());

    String[] tableNames = new String[4];
    for (int i = 0; i < tableNames.length; i++) {
      tableNames[i] = "table_in_other_catalog_" + i;
      new TableBuilder()
          .inDb(db)
          .setTableName(tableNames[i])
          .addCol("col1_" + i, ColumnType.STRING_TYPE_NAME)
          .addCol("col2_" + i, ColumnType.INT_TYPE_NAME)
          .create(client, metaStore.getConf());
    }

    Set<String> tables = new HashSet<>(client.getTables(catName, dbName, "*e_in_other_*"));
    Assert.assertEquals(4, tables.size());
    for (String tableName : tableNames) Assert.assertTrue(tables.contains(tableName));

    List<String> fetchedNames = client.getTables(catName, dbName, "*_3");
    Assert.assertEquals(1, fetchedNames.size());
    Assert.assertEquals(tableNames[3], fetchedNames.get(0));

    Assert.assertTrue("Table exists", client.tableExists(catName, dbName, tableNames[0]));
    Assert.assertFalse("Table not exists", client.tableExists(catName, dbName, "non_existing_table"));
  }
Test class for IMetaStoreClient API. Testing the Table related functions for metadata
querying like getting one, or multiple tables, and table name lists.
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesGetExists.java