Java Code Examples for org.apache.hadoop.hive.metastore.Warehouse#getQualifiedName()

The following examples show how to use org.apache.hadoop.hive.metastore.Warehouse#getQualifiedName() . 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: ViewTransformation.java    From circus-train with Apache License 2.0 6 votes vote down vote up
@Override
public Table transform(Table table) {
  if (!MetaStoreUtils.isView(table)) {
    return table;
  }

  LOG.info("Translating HQL of view {}.{}", table.getDbName(), table.getTableName());
  String tableQualifiedName = Warehouse.getQualifiedName(table);
  String hql = hqlTranslator.translate(tableQualifiedName, table.getViewOriginalText());
  String expandedHql = hqlTranslator.translate(tableQualifiedName, table.getViewExpandedText());

  Table transformedView = new Table(table);
  transformedView.setViewOriginalText(hql);
  transformedView.setViewExpandedText(expandedHql);

  if (!replicaHiveConf.getBoolean(SKIP_TABLE_EXIST_CHECKS, false)) {
    LOG
        .info("Validating that tables used by the view {}.{} exist in the replica catalog", table.getDbName(),
            table.getTableName());
    validateReferencedTables(transformedView);
  }

  return transformedView;
}
 
Example 2
Source File: BufferedPartitionFetcher.java    From circus-train with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
void bufferPartitions(int firstPartition) {
  int totalPartitionsToLoad = Math.min(partitionNames.size(), firstPartition + bufferSize);
  List<String> partitionsToLoad = partitionNames.subList(firstPartition, totalPartitionsToLoad);

  try {
    LOG.debug("Fetching {} partitions.", totalPartitionsToLoad);
    List<Partition> partitions = metastore.getPartitionsByNames(table.getDbName(), table.getTableName(),
        partitionsToLoad);
    LOG.debug("Fetched {} partitions for table {}.", partitions.size(), Warehouse.getQualifiedName(table));

    buffer = new HashMap<>(partitions.size());
    for (Partition partition : partitions) {
      buffer.put(Warehouse.makePartName(table.getPartitionKeys(), partition.getValues()), partition);
    }
  } catch (TException e) {
    throw new RuntimeException("Unable to fetch partitions of table " + Warehouse.getQualifiedName(table), e);
  }
}
 
Example 3
Source File: BufferedPartitionFetcher.java    From circus-train with Apache License 2.0 5 votes vote down vote up
public BufferedPartitionFetcher(IMetaStoreClient metastore, Table table, short bufferSize) {

    try {
      LOG.debug("Fetching all partition names.");
      partitionNames = metastore.listPartitionNames(table.getDbName(), table.getTableName(), NO_LIMIT);
      LOG.debug("Fetched {} partition names for table {}.", partitionNames.size(), Warehouse.getQualifiedName(table));
    } catch (TException e) {
      throw new RuntimeException("Unable to fetch partition names of table " + Warehouse.getQualifiedName(table), e);
    }

    this.table = table;
    this.metastore = metastore;
    this.bufferSize = bufferSize;
    buffer = Collections.emptyMap();
  }
 
Example 4
Source File: DestinationNotReplicaException.java    From circus-train with Apache License 2.0 5 votes vote down vote up
DestinationNotReplicaException(
    Table oldReplicaTable,
    String replicaMetastoreUris,
    CircusTrainTableParameter tableParameter) {
  super("Found an existing table '"
      + Warehouse.getQualifiedName(oldReplicaTable)
      + "' in '"
      + replicaMetastoreUris
      + "', but it does not appear to be a replica! Missing table property '"
      + tableParameter.parameterName()
      + "'");
}
 
Example 5
Source File: HiveDifferences.java    From circus-train with Apache License 2.0 5 votes vote down vote up
private static String partitionName(Table table, Partition partition) {
  try {
    return Warehouse.makePartName(table.getPartitionKeys(), partition.getValues());
  } catch (MetaException e) {
    throw new CircusTrainException("Unable to build partition name for partition values "
        + partition.getValues()
        + " of table "
        + Warehouse.getQualifiedName(table), e);
  }
}
 
Example 6
Source File: HiveDifferences.java    From circus-train with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
static TableAndMetadata sourceTableToTableAndMetadata(Table sourceTable) {
  return new TableAndMetadata(Warehouse.getQualifiedName(sourceTable),
      normaliseLocation(sourceTable.getSd().getLocation()), sourceTable);
}
 
Example 7
Source File: TestUtils.java    From circus-train with Apache License 2.0 4 votes vote down vote up
public static TableAndMetadata newTableAndMetadata(String database, String tableName) {
  Table table = newTable(database, tableName);
  return new TableAndMetadata(Warehouse.getQualifiedName(table), table.getSd().getLocation(), table);
}