org.apache.kudu.client.AlterTableOptions Java Examples
The following examples show how to use
org.apache.kudu.client.AlterTableOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KuduClientSession.java From presto with Apache License 2.0 | 5 votes |
public void renameTable(SchemaTableName schemaTableName, SchemaTableName newSchemaTableName) { 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); } }
Example #2
Source File: KuduClientSession.java From presto with Apache License 2.0 | 5 votes |
public void addColumn(SchemaTableName schemaTableName, ColumnMetadata column) { 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); } }
Example #3
Source File: KuduClientSession.java From presto with Apache License 2.0 | 5 votes |
public void dropColumn(SchemaTableName schemaTableName, String name) { 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); } }
Example #4
Source File: KuduClientSession.java From presto with Apache License 2.0 | 5 votes |
public void renameColumn(SchemaTableName schemaTableName, String oldName, String newName) { 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); } }
Example #5
Source File: KuduClientSession.java From presto with Apache License 2.0 | 5 votes |
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); } }
Example #6
Source File: NativeKuduClientSession.java From presto-kudu with Apache License 2.0 | 5 votes |
@Override public void renameTable(SchemaTableName schemaTableName, SchemaTableName newSchemaTableName) { try { String rawName = toRawName(schemaTableName); String newRawName = toRawName(newSchemaTableName); AlterTableOptions alterOptions = new AlterTableOptions(); alterOptions.renameTable(newRawName); client.alterTable(rawName, alterOptions); } catch (KuduException e) { throw new PrestoException(GENERIC_INTERNAL_ERROR, e); } }
Example #7
Source File: NativeKuduClientSession.java From presto-kudu with Apache License 2.0 | 5 votes |
@Override public void addColumn(SchemaTableName schemaTableName, ColumnMetadata column) { try { String rawName = 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); } }
Example #8
Source File: NativeKuduClientSession.java From presto-kudu with Apache License 2.0 | 5 votes |
@Override public void dropColumn(SchemaTableName schemaTableName, String name) { try { String rawName = toRawName(schemaTableName); AlterTableOptions alterOptions = new AlterTableOptions(); alterOptions.dropColumn(name); client.alterTable(rawName, alterOptions); } catch (KuduException e) { throw new PrestoException(GENERIC_INTERNAL_ERROR, e); } }
Example #9
Source File: NativeKuduClientSession.java From presto-kudu with Apache License 2.0 | 5 votes |
@Override public void renameColumn(SchemaTableName schemaTableName, String oldName, String newName) { try { String rawName = toRawName(schemaTableName); AlterTableOptions alterOptions = new AlterTableOptions(); alterOptions.renameColumn(oldName, newName); client.alterTable(rawName, alterOptions); } catch (KuduException e) { throw new PrestoException(GENERIC_INTERNAL_ERROR, e); } }
Example #10
Source File: KuduCatalog.java From bahir-flink with Apache License 2.0 | 5 votes |
@Override public void renameTable(ObjectPath tablePath, String newTableName, boolean ignoreIfNotExists) throws TableNotExistException { String tableName = tablePath.getObjectName(); try { if (tableExists(tablePath)) { kuduClient.alterTable(tableName, new AlterTableOptions().renameTable(newTableName)); } else if (!ignoreIfNotExists) { throw new TableNotExistException(getName(), tablePath); } } catch (KuduException e) { throw new CatalogException("Could not rename table " + tableName, e); } }
Example #11
Source File: AbstractKuduProcessor.java From nifi with Apache License 2.0 | 5 votes |
/** * Based on NiFi field declaration, generates an alter statement to extend table with new column. Note: simply calling * {@link AlterTableOptions#addNullableColumn(String, Type)} is not sufficient as it does not cover BigDecimal scale and precision handling. * * @param columnName Name of the new table column. * @param nifiType Type of the field. * * @return Alter table statement to extend table with the new field. */ protected AlterTableOptions getAddNullableColumnStatement(final String columnName, final DataType nifiType) { final AlterTableOptions alterTable = new AlterTableOptions(); alterTable.addColumn(new ColumnSchema.ColumnSchemaBuilder(columnName, toKuduType(nifiType)) .nullable(true) .defaultValue(null) .typeAttributes(getKuduTypeAttributes(nifiType)) .build()); return alterTable; }