use of org.apache.kudu.client.AlterTableOptions in project presto by prestodb.
the class KuduClientSession method renameColumn.
public void renameColumn(SchemaTableName schemaTableName, String oldName, String newName) {
reTryKerberos(kerberosAuthEnabled);
try {
String rawName = schemaEmulation.toRawName(schemaTableName);
AlterTableOptions alterOptions = new AlterTableOptions();
alterOptions.renameColumn(oldName, newName);
client.alterTable(rawName, alterOptions);
} catch (KuduException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, e);
}
}
use of org.apache.kudu.client.AlterTableOptions in project presto by prestodb.
the class KuduClientSession method addColumn.
public void addColumn(SchemaTableName schemaTableName, ColumnMetadata column) {
reTryKerberos(kerberosAuthEnabled);
try {
String rawName = schemaEmulation.toRawName(schemaTableName);
AlterTableOptions alterOptions = new AlterTableOptions();
Type type = TypeHelper.toKuduClientType(column.getType());
alterOptions.addNullableColumn(column.getName(), type);
client.alterTable(rawName, alterOptions);
} catch (KuduException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, e);
}
}
use of org.apache.kudu.client.AlterTableOptions in project presto by prestodb.
the class KuduClientSession method dropColumn.
public void dropColumn(SchemaTableName schemaTableName, String name) {
reTryKerberos(kerberosAuthEnabled);
try {
String rawName = schemaEmulation.toRawName(schemaTableName);
AlterTableOptions alterOptions = new AlterTableOptions();
alterOptions.dropColumn(name);
client.alterTable(rawName, alterOptions);
} catch (KuduException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, e);
}
}
use of org.apache.kudu.client.AlterTableOptions in project presto by prestodb.
the class KuduClientSession method renameTable.
public void renameTable(SchemaTableName schemaTableName, SchemaTableName newSchemaTableName) {
reTryKerberos(kerberosAuthEnabled);
try {
String rawName = schemaEmulation.toRawName(schemaTableName);
String newRawName = schemaEmulation.toRawName(newSchemaTableName);
AlterTableOptions alterOptions = new AlterTableOptions();
alterOptions.renameTable(newRawName);
client.alterTable(rawName, alterOptions);
} catch (KuduException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, e);
}
}
use of org.apache.kudu.client.AlterTableOptions in project presto by prestodb.
the class KuduClientSession method changeRangePartition.
private void changeRangePartition(SchemaTableName schemaTableName, RangePartition rangePartition, RangePartitionChange change) {
try {
String rawName = schemaEmulation.toRawName(schemaTableName);
KuduTable table = client.openTable(rawName);
Schema schema = table.getSchema();
PartitionDesign design = KuduTableProperties.getPartitionDesign(table);
RangePartitionDefinition definition = design.getRange();
if (definition == null) {
throw new PrestoException(QUERY_REJECTED, "Table " + schemaTableName + " has no range partition");
}
PartialRow lowerBound = KuduTableProperties.toRangeBoundToPartialRow(schema, definition, rangePartition.getLower());
PartialRow upperBound = KuduTableProperties.toRangeBoundToPartialRow(schema, definition, rangePartition.getUpper());
AlterTableOptions alterOptions = new AlterTableOptions();
switch(change) {
case ADD:
alterOptions.addRangePartition(lowerBound, upperBound);
break;
case DROP:
alterOptions.dropRangePartition(lowerBound, upperBound);
break;
}
client.alterTable(rawName, alterOptions);
} catch (KuduException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, e);
}
}
Aggregations