use of io.trino.spi.connector.ColumnNotFoundException in project trino by trinodb.
the class GlueHiveMetastore method dropColumn.
@Override
public void dropColumn(String databaseName, String tableName, String columnName) {
verifyCanDropColumn(this, databaseName, tableName, columnName);
Table oldTable = getExistingTable(databaseName, tableName);
if (oldTable.getColumn(columnName).isEmpty()) {
SchemaTableName name = new SchemaTableName(databaseName, tableName);
throw new ColumnNotFoundException(name, columnName);
}
ImmutableList.Builder<Column> newDataColumns = ImmutableList.builder();
oldTable.getDataColumns().stream().filter(fieldSchema -> !fieldSchema.getName().equals(columnName)).forEach(newDataColumns::add);
Table newTable = Table.builder(oldTable).setDataColumns(newDataColumns.build()).build();
replaceTable(databaseName, tableName, newTable, null);
}
use of io.trino.spi.connector.ColumnNotFoundException 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.ColumnNotFoundException in project trino by trinodb.
the class AtopMetadata method getColumnMetadata.
@Override
public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle) {
String columnName = ((AtopColumnHandle) columnHandle).getName();
for (ColumnMetadata column : getTableMetadata(session, tableHandle).getColumns()) {
if (column.getName().equals(columnName)) {
return column;
}
}
AtopTableHandle atopTableHandle = (AtopTableHandle) tableHandle;
SchemaTableName tableName = new SchemaTableName(atopTableHandle.getSchema(), atopTableHandle.getTable().getName());
throw new ColumnNotFoundException(tableName, columnName);
}
Aggregations