org.apache.hadoop.hive.metastore.api.SQLForeignKey Java Examples

The following examples show how to use org.apache.hadoop.hive.metastore.api.SQLForeignKey. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FederatedHMSHandlerTest.java    From waggle-dance with Apache License 2.0 6 votes vote down vote up
@Test
public void get_foreign_keys() throws TException {
  ForeignKeysRequest request = new ForeignKeysRequest();
  request.setParent_db_name(null);
  request.setParent_tbl_name(null);
  request.setForeign_db_name(DB_S);
  request.setForeign_tbl_name("table");
  SQLForeignKey key = new SQLForeignKey();
  key.setFktable_db(DB_S);
  key.setFktable_name("table");
  ForeignKeysResponse response = new ForeignKeysResponse(Collections.singletonList(key));

  when(databaseMappingService.databaseMapping(request.getForeign_db_name())).thenReturn(primaryMapping);
  when(primaryMapping.transformInboundForeignKeysRequest(request)).thenReturn(request);
  when(primaryClient.get_foreign_keys(request)).thenReturn(response);
  response.getForeignKeys().get(0).setFktable_db(DB_P);
  when(primaryMapping.transformOutboundForeignKeysResponse(response)).thenReturn(response);

  ForeignKeysResponse result = handler.get_foreign_keys(request);
  assertThat(result.getForeignKeys().get(0).getFktable_db(), is(DB_P));
  assertThat(result.getForeignKeys().get(0).getFktable_name(), is("table"));
}
 
Example #2
Source File: GlueMetastoreClientDelegate.java    From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 5 votes vote down vote up
public void createTableWithConstraints(
    org.apache.hadoop.hive.metastore.api.Table table,
    List<SQLPrimaryKey> primaryKeys,
    List<SQLForeignKey> foreignKeys
) throws AlreadyExistsException, TException {
  throw new UnsupportedOperationException("createTableWithConstraints is not supported");
}
 
Example #3
Source File: AWSCatalogMetastoreClient.java    From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 5 votes vote down vote up
@Override
public void createTableWithConstraints(
    org.apache.hadoop.hive.metastore.api.Table table,
    List<SQLPrimaryKey> primaryKeys,
    List<SQLForeignKey> foreignKeys
) throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException, TException {
  glueMetastoreClientDelegate.createTableWithConstraints(table, primaryKeys, foreignKeys);
}
 
Example #4
Source File: DatabaseMappingImpl.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Override
public ForeignKeysResponse transformOutboundForeignKeysResponse(ForeignKeysResponse response) {
  for (SQLForeignKey key : response.getForeignKeys()) {
    key.setPktable_db(metaStoreMapping.transformOutboundDatabaseName(key.getPktable_db()));
    key.setFktable_db(metaStoreMapping.transformOutboundDatabaseName(key.getFktable_db()));
  }
  return response;
}
 
Example #5
Source File: FederatedHMSHandler.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Override
@Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME)
public void create_table_with_constraints(Table tbl, List<SQLPrimaryKey> primaryKeys, List<SQLForeignKey> foreignKeys)
    throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException, TException {
  DatabaseMapping mapping = checkWritePermissions(tbl.getDbName());
  mapping.getClient().create_table_with_constraints(mapping.transformInboundTable(tbl), primaryKeys, foreignKeys);
}
 
Example #6
Source File: DatabaseMappingImplTest.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Test
public void transformOutboundForeignKeysResponse() throws Exception {
  SQLForeignKey foreignKey = new SQLForeignKey();
  foreignKey.setPktable_db(DB_NAME);
  foreignKey.setFktable_db(DB_NAME);
  ForeignKeysResponse foreignKeysResponse = new ForeignKeysResponse(Collections.singletonList(foreignKey));
  ForeignKeysResponse result = databaseMapping.transformOutboundForeignKeysResponse(foreignKeysResponse);
  assertThat(result, is(sameInstance(foreignKeysResponse)));
  assertThat(result.getForeignKeys().size(), is(1));
  assertThat(result.getForeignKeys().get(0), is(sameInstance(foreignKeysResponse.getForeignKeys().get(0))));
  assertThat(result.getForeignKeys().get(0).getPktable_db(), is(OUT_DB_NAME));
  assertThat(result.getForeignKeys().get(0).getFktable_db(), is(OUT_DB_NAME));
}
 
Example #7
Source File: FederatedHMSHandlerTest.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Test
public void create_table_with_constraints() throws TException {
  Table table = new Table();
  table.setDbName(DB_P);
  Table inboundTable = new Table();
  List<SQLPrimaryKey> primaryKeys = Collections.emptyList();
  List<SQLForeignKey> foreignKeys = Collections.emptyList();
  when(primaryMapping.transformInboundTable(table)).thenReturn(inboundTable);
  handler.create_table_with_constraints(table, primaryKeys, foreignKeys);
  verify(primaryMapping).checkWritePermissions(DB_P);
  verify(primaryClient).create_table_with_constraints(inboundTable, primaryKeys, foreignKeys);
}
 
Example #8
Source File: SubmarineMetaStore.java    From submarine with Apache License 2.0 4 votes vote down vote up
public void createTableWithConstraints(Table tbl,
                                       List<SQLPrimaryKey> primaryKeys,
                                       List<SQLForeignKey> foreignKeys)
    throws InvalidObjectException, MetaException {
  rs.createTableWithConstraints(tbl, primaryKeys, foreignKeys);
}
 
Example #9
Source File: GlueMetastoreClientDelegate.java    From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 4 votes vote down vote up
public void addForeignKey(List<SQLForeignKey> foreignKeyCols) throws TException {
  throw new UnsupportedOperationException("addForeignKey is not supported");
}
 
Example #10
Source File: AWSCatalogMetastoreClient.java    From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 4 votes vote down vote up
@Override
public List<SQLForeignKey> getForeignKeys(ForeignKeysRequest foreignKeysRequest) throws MetaException, NoSuchObjectException, TException {
  // PrimaryKeys are currently unsupported
  //return null to allow DESCRIBE (FORMATTED | EXTENDED)
  return null;
}
 
Example #11
Source File: AWSCatalogMetastoreClient.java    From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 4 votes vote down vote up
@Override
public void addForeignKey(List<SQLForeignKey> foreignKeyCols)
    throws MetaException, NoSuchObjectException, TException {
  glueMetastoreClientDelegate.addForeignKey(foreignKeyCols);
}