Search in sources :

Example 1 with NotFoundException

use of org.apache.iceberg.exceptions.NotFoundException in project metacat by Netflix.

the class IcebergTableHandler method getIcebergTable.

/**
 * get iceberg table.
 *
 * @param tableName             table name
 * @param tableMetadataLocation table metadata location
 * @param includeInfoDetails    if true, will include more details like the manifest file content
 * @return iceberg table
 */
public IcebergTableWrapper getIcebergTable(final QualifiedName tableName, final String tableMetadataLocation, final boolean includeInfoDetails) {
    final long start = this.registry.clock().wallTime();
    try {
        this.icebergTableCriteria.checkCriteria(tableName, tableMetadataLocation);
        log.debug("Loading icebergTable {} from {}", tableName, tableMetadataLocation);
        final IcebergMetastoreTables icebergMetastoreTables = new IcebergMetastoreTables(new IcebergTableOps(conf, tableMetadataLocation, connectorContext.getConfig(), icebergTableOpsProxy));
        final Table table = icebergMetastoreTables.loadTable(HiveTableUtil.qualifiedNameToTableIdentifier(tableName));
        final Map<String, String> extraProperties = Maps.newHashMap();
        if (includeInfoDetails) {
            extraProperties.put(DirectSqlTable.PARAM_METADATA_CONTENT, TableMetadataParser.toJson(icebergMetastoreTables.getTableOps().current()));
        }
        return new IcebergTableWrapper(table, extraProperties);
    } catch (NotFoundException | NoSuchTableException e) {
        throw new InvalidMetaException(tableName, e);
    } finally {
        final long duration = registry.clock().wallTime() - start;
        log.info("Time taken to getIcebergTable {} is {} ms", tableName, duration);
        this.recordTimer(IcebergRequestMetrics.TagLoadTable.getMetricName(), duration);
        this.increaseCounter(IcebergRequestMetrics.TagLoadTable.getMetricName(), tableName);
    }
}
Also used : DirectSqlTable(com.netflix.metacat.connector.hive.sql.DirectSqlTable) Table(org.apache.iceberg.Table) NoSuchTableException(org.apache.iceberg.exceptions.NoSuchTableException) NotFoundException(org.apache.iceberg.exceptions.NotFoundException) InvalidMetaException(com.netflix.metacat.common.server.connectors.exception.InvalidMetaException)

Aggregations

InvalidMetaException (com.netflix.metacat.common.server.connectors.exception.InvalidMetaException)1 DirectSqlTable (com.netflix.metacat.connector.hive.sql.DirectSqlTable)1 Table (org.apache.iceberg.Table)1 NoSuchTableException (org.apache.iceberg.exceptions.NoSuchTableException)1 NotFoundException (org.apache.iceberg.exceptions.NotFoundException)1