use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.
the class FileHiveMetastore method dropColumn.
@Override
public synchronized void dropColumn(String databaseName, String tableName, String columnName) {
alterTable(databaseName, tableName, oldTable -> {
verifyCanDropColumn(this, databaseName, tableName, columnName);
if (oldTable.getColumn(columnName).isEmpty()) {
SchemaTableName name = new SchemaTableName(databaseName, tableName);
throw new ColumnNotFoundException(name, columnName);
}
ImmutableList.Builder<Column> newDataColumns = ImmutableList.builder();
for (Column fieldSchema : oldTable.getDataColumns()) {
if (!fieldSchema.getName().equals(columnName)) {
newDataColumns.add(fieldSchema);
}
}
return oldTable.withDataColumns(currentVersion, newDataColumns.build());
});
}
use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.
the class FileHiveMetastore method getTableStatistics.
private synchronized PartitionStatistics getTableStatistics(String databaseName, String tableName) {
Path tableMetadataDirectory = getTableMetadataDirectory(databaseName, tableName);
TableMetadata tableMetadata = readSchemaFile(TABLE, tableMetadataDirectory, tableCodec).orElseThrow(() -> new TableNotFoundException(new SchemaTableName(databaseName, tableName)));
checkVersion(tableMetadata.getWriterVersion());
HiveBasicStatistics basicStatistics = getHiveBasicStatistics(tableMetadata.getParameters());
Map<String, HiveColumnStatistics> columnStatistics = tableMetadata.getColumnStatistics();
return new PartitionStatistics(basicStatistics, columnStatistics);
}
use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.
the class BridgingHiveMetastore method renameTable.
@Override
public void renameTable(String databaseName, String tableName, String newDatabaseName, String newTableName) {
Optional<org.apache.hadoop.hive.metastore.api.Table> source = delegate.getTable(identity, databaseName, tableName);
if (source.isEmpty()) {
throw new TableNotFoundException(new SchemaTableName(databaseName, tableName));
}
org.apache.hadoop.hive.metastore.api.Table table = source.get();
table.setDbName(newDatabaseName);
table.setTableName(newTableName);
alterTable(databaseName, tableName, table);
}
use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.
the class BridgingHiveMetastore method addColumn.
@Override
public void addColumn(String databaseName, String tableName, String columnName, HiveType columnType, String columnComment) {
Optional<org.apache.hadoop.hive.metastore.api.Table> source = delegate.getTable(identity, databaseName, tableName);
if (source.isEmpty()) {
throw new TableNotFoundException(new SchemaTableName(databaseName, tableName));
}
org.apache.hadoop.hive.metastore.api.Table table = source.get();
table.getSd().getCols().add(new FieldSchema(columnName, columnType.getHiveTypeName().toString(), columnComment));
alterTable(databaseName, tableName, table);
}
use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.
the class BridgingHiveMetastore method commentTable.
@Override
public void commentTable(String databaseName, String tableName, Optional<String> comment) {
Optional<org.apache.hadoop.hive.metastore.api.Table> source = delegate.getTable(identity, databaseName, tableName);
if (source.isEmpty()) {
throw new TableNotFoundException(new SchemaTableName(databaseName, tableName));
}
org.apache.hadoop.hive.metastore.api.Table table = source.get();
Map<String, String> parameters = table.getParameters().entrySet().stream().filter(entry -> !entry.getKey().equals(TABLE_COMMENT)).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
comment.ifPresent(value -> parameters.put(TABLE_COMMENT, value));
table.setParameters(parameters);
alterTable(databaseName, tableName, table);
}
Aggregations