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());
}
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;
}
Aggregations