use of org.apache.iceberg.BaseTable in project presto by prestodb.
the class IcebergUtil method getHiveIcebergTable.
public static Table getHiveIcebergTable(ExtendedHiveMetastore metastore, HdfsEnvironment hdfsEnvironment, ConnectorSession session, SchemaTableName table) {
HdfsContext hdfsContext = new HdfsContext(session, table.getSchemaName(), table.getTableName());
TableOperations operations = new HiveTableOperations(metastore, new MetastoreContext(session.getIdentity(), session.getQueryId(), session.getClientInfo(), session.getSource(), Optional.empty(), false, HiveColumnConverterProvider.DEFAULT_COLUMN_CONVERTER_PROVIDER), hdfsEnvironment, hdfsContext, table.getSchemaName(), table.getTableName());
return new BaseTable(operations, quotedTableName(table));
}
use of org.apache.iceberg.BaseTable in project hive by apache.
the class HiveIcebergMetaHook method rollbackAlterTable.
@Override
public void rollbackAlterTable(org.apache.hadoop.hive.metastore.api.Table hmsTable, EnvironmentContext context) {
if (Boolean.parseBoolean(context.getProperties().getOrDefault(MIGRATE_HIVE_TO_ICEBERG, "false"))) {
LOG.debug("Initiating rollback for table {} at location {}", hmsTable.getTableName(), hmsTable.getSd().getLocation());
context.getProperties().put(INITIALIZE_ROLLBACK_MIGRATION, "true");
this.catalogProperties = getCatalogProperties(hmsTable);
try {
this.icebergTable = Catalogs.loadTable(conf, catalogProperties);
} catch (NoSuchTableException nte) {
// iceberg table was not yet created, no need to delete the metadata dir separately
return;
}
// we want to keep the data files but get rid of the metadata directory
String metadataLocation = ((BaseTable) this.icebergTable).operations().current().metadataFileLocation();
try {
Path path = new Path(metadataLocation).getParent();
FileSystem.get(path.toUri(), conf).delete(path, true);
LOG.debug("Metadata directory of iceberg table {} at location {} was deleted", icebergTable.name(), path);
} catch (IOException e) {
// the file doesn't exists, do nothing
}
}
}
use of org.apache.iceberg.BaseTable in project hive by apache.
the class TestInputFormatReaderDeletes method createTable.
@Override
protected Table createTable(String name, Schema schema, PartitionSpec spec) throws IOException {
Table table;
File location = temp.newFolder(inputFormat, fileFormat.name());
Assert.assertTrue(location.delete());
helper = new TestHelper(conf, tables, location.toString(), schema, spec, fileFormat, temp);
table = helper.createTable();
TableOperations ops = ((BaseTable) table).operations();
TableMetadata meta = ops.current();
ops.commit(meta, meta.upgradeToFormatVersion(2));
return table;
}
Aggregations