public Optional<Schema> getTableSchema(String db, String table) {
    try {
      org.apache.hadoop.hive.metastore.api.Table metastoreTable = metastore.getTable(db, table);
      List<FieldSchema> fields = Lists.newArrayList(metastoreTable.getSd().getCols());
      fields.addAll(metastoreTable.getPartitionKeys());
      Schema schema = SchemaUtils.toBeamSchema(fields);
      return Optional.of(schema);
    } catch (NoSuchObjectException e) {
      return Optional.absent();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
@Test
  public void testGetTableSchema() {
    HCatalogBeamSchema hcatSchema = HCatalogBeamSchema.create(service.getHiveConfAsMap());
    Schema schema = hcatSchema.getTableSchema(TEST_DATABASE, TEST_TABLE).get();

    Schema expectedSchema =
        Schema.builder()
            .addNullableField("mycol1", Schema.FieldType.STRING)
            .addNullableField("mycol2", Schema.FieldType.INT32)
            .build();

    assertEquals(expectedSchema, schema);
  }