Search in sources :

Example 11 with NoSuchTableException

use of org.apache.iceberg.exceptions.NoSuchTableException in project presto by prestodb.

the class IcebergHadoopMetadata method getTableHandle.

@Override
public IcebergTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName) {
    IcebergTableName name = IcebergTableName.from(tableName.getTableName());
    verify(name.getTableType() == DATA, "Wrong table type: " + name.getTableType());
    TableIdentifier tableIdentifier = toIcebergTableIdentifier(tableName.getSchemaName(), name.getTableName());
    Table table;
    try {
        table = resourceFactory.getCatalog(session).loadTable(tableIdentifier);
    } catch (NoSuchTableException e) {
        // return null to throw
        return null;
    }
    return new IcebergTableHandle(tableName.getSchemaName(), name.getTableName(), name.getTableType(), resolveSnapshotIdByName(table, name), TupleDomain.all());
}
Also used : TableIdentifier(org.apache.iceberg.catalog.TableIdentifier) IcebergPrestoModelConverters.toIcebergTableIdentifier(com.facebook.presto.iceberg.util.IcebergPrestoModelConverters.toIcebergTableIdentifier) SystemTable(com.facebook.presto.spi.SystemTable) IcebergUtil.getHadoopIcebergTable(com.facebook.presto.iceberg.IcebergUtil.getHadoopIcebergTable) Table(org.apache.iceberg.Table) NoSuchTableException(org.apache.iceberg.exceptions.NoSuchTableException)

Example 12 with NoSuchTableException

use of org.apache.iceberg.exceptions.NoSuchTableException in project drill by apache.

the class IcebergMetastore method loadTable.

/**
 * Creates / loads Iceberg table for specific component based on given location
 * and config properties and table schema.
 * Updates table properties for existing Iceberg table only once based on
 * {@link #loadStatusMap} status.
 *
 * @param componentLocationConfig path to component location config
 * @param componentPropertiesConfig path to component properties config
 * @param schema Iceberg table schema
 * @param loadClass Metastore component implementation interface
 * @return Iceberg table instance
 */
private Table loadTable(String componentLocationConfig, String componentPropertiesConfig, IcebergTableSchema schema, Class<?> loadClass) {
    String location = tableLocation(componentLocationConfig);
    Map<String, String> tableProperties = tableProperties(componentPropertiesConfig);
    Table table;
    try {
        table = tables.load(location);
    } catch (NoSuchTableException e) {
        try {
            // creating new Iceberg table, no need to update table properties
            return tables.create(schema.tableSchema(), schema.partitionSpec(), tableProperties, location);
        } catch (AlreadyExistsException ex) {
            table = tables.load(location);
        }
    }
    // updates table properties only during first component table call
    if (loadStatusMap.putIfAbsent(loadClass, Boolean.TRUE) == null) {
        updateTableProperties(table, tableProperties);
    }
    return table;
}
Also used : Table(org.apache.iceberg.Table) AlreadyExistsException(org.apache.iceberg.exceptions.AlreadyExistsException) NoSuchTableException(org.apache.iceberg.exceptions.NoSuchTableException)

Aggregations

NoSuchTableException (org.apache.iceberg.exceptions.NoSuchTableException)12 Table (org.apache.iceberg.Table)6 IcebergUtil.getHadoopIcebergTable (com.facebook.presto.iceberg.IcebergUtil.getHadoopIcebergTable)3 SystemTable (com.facebook.presto.spi.SystemTable)3 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)3 TableIdentifier (org.apache.iceberg.catalog.TableIdentifier)3 TException (org.apache.thrift.TException)3 IcebergPrestoModelConverters.toIcebergTableIdentifier (com.facebook.presto.iceberg.util.IcebergPrestoModelConverters.toIcebergTableIdentifier)2 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)2 Table (org.apache.hadoop.hive.metastore.api.Table)2 PartitionSpec (org.apache.iceberg.PartitionSpec)2 Schema (org.apache.iceberg.Schema)2 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)1 ConnectorTableMetadata (com.facebook.presto.spi.ConnectorTableMetadata)1 PrestoException (com.facebook.presto.spi.PrestoException)1 TableNotFoundException (com.facebook.presto.spi.TableNotFoundException)1 InvalidMetaException (com.netflix.metacat.common.server.connectors.exception.InvalidMetaException)1 DirectSqlTable (com.netflix.metacat.connector.hive.sql.DirectSqlTable)1 IOException (java.io.IOException)1 List (java.util.List)1