Java Code Examples for org.apache.hadoop.hive.ql.metadata.Table#setDbName()

The following examples show how to use org.apache.hadoop.hive.ql.metadata.Table#setDbName() . 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: HiveCopyEntityHelper.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
static void addMetadataToTargetTable(Table targetTable, Path targetLocation, String targetDatabase, long startTime)
    throws IOException {
  targetTable.setDbName(targetDatabase);
  targetTable.setDataLocation(targetLocation);
  /*
   * Need to set the table owner as the flow executor
   */
  targetTable.setOwner(UserGroupInformation.getCurrentUser().getShortUserName());
  targetTable.getTTable().putToParameters(HiveDataset.REGISTERER, GOBBLIN_DISTCP);
  targetTable.getTTable().putToParameters(HiveDataset.REGISTRATION_GENERATION_TIME_MILLIS,
      Long.toString(startTime));

  /**
   * Only set the this constants when source table has it.
   */
  targetTable.getTTable().getSd().getSerdeInfo().getParameters()
      .computeIfPresent(HiveConstants.PATH, (k,v) -> targetLocation.toString());
  targetTable.getTTable().unsetCreateTime();
}
 
Example 2
Source File: HiveTargetPathHelperTest.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private HiveTargetPathHelper createTestTargetPathHelper(Properties properties) {
  HiveDataset dataset = Mockito.mock(HiveDataset.class);

  Table table = new Table(new org.apache.hadoop.hive.metastore.api.Table());
  table.setDbName("dbName");
  table.setTableName("tableName");
  Mockito.when(dataset.getTable()).thenReturn(table);

  Mockito.when(dataset.getTableRootPath()).thenReturn(Optional.of(TABLE_ROOT));
  Mockito.when(dataset.getProperties()).thenReturn(properties);

  HiveTargetPathHelper helper = new HiveTargetPathHelper(dataset);

  return helper;
}
 
Example 3
Source File: SimpleHiveDatasetTieringPrioritizerTest.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private CopyableDatasetRequestor getRequestor(String dbName, String tableName) {
  CopyableDatasetRequestor requestor = Mockito.mock(CopyableDatasetRequestor.class);
  HiveDataset dataset = Mockito.mock(HiveDataset.class);

  Table table = new Table(new org.apache.hadoop.hive.metastore.api.Table());
  table.setDbName(dbName);
  table.setTableName(tableName);

  Mockito.when(dataset.getTable()).thenReturn(table);
  Mockito.when(requestor.getDataset()).thenReturn(dataset);

  return requestor;
}