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); } }
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); } }
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); } }
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); } }
AlterTableOptions alterOptions = new AlterTableOptions(); switch (change) { case ADD:
AlterTableOptions alterTableOptions = new AlterTableOptions(); AtomicBoolean updated = new AtomicBoolean(false); Schema schema = table.getSchema();
@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); } }
@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); } }
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); } }
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); } }
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); } }
@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); } }
@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); } }
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); } }
private void changeRangePartition(SchemaTableName schemaTableName, RangePartition rangePartition, RangePartitionChange change) { try { String rawName = 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 (PrestoException e) { throw e; } catch (KuduException e) { throw new PrestoException(GENERIC_INTERNAL_ERROR, e); } }
AlterTableOptions alterOptions = new AlterTableOptions(); switch (change) { case ADD:
@Test(timeout = 100000) public void testCreateTableWithConcurrentAlter() throws Exception { // Kick off an asynchronous table creation. Deferred<KuduTable> d = asyncClient.createTable(TABLE_NAME, createManyStringsSchema(), getBasicCreateTableOptions()); // Rename the table that's being created to make sure it doesn't interfere // with the "wait for all tablets to be created" behavior of createTable(). // // We have to retry this in a loop because we might run before the table // actually exists. while (true) { try { client.alterTable(TABLE_NAME, new AlterTableOptions().renameTable("foo")); break; } catch (KuduException e) { if (!e.getStatus().isNotFound()) { throw e; } } } // If createTable() was disrupted by the alterTable(), this will throw. d.join(); }
@Test public void testAlterModifyColumns() throws Exception { KuduTable table = createTable(ImmutableList.<Pair<Integer,Integer>>of()); insertRows(table, 0, 100); assertEquals(100, countRowsInTable(table)); // Check for expected defaults. ColumnSchema col = table.getSchema().getColumns().get(1); assertEquals(CompressionAlgorithm.DEFAULT_COMPRESSION, col.getCompressionAlgorithm()); assertEquals(Encoding.AUTO_ENCODING, col.getEncoding()); assertEquals(null, col.getDefaultValue()); // Alter the table. client.alterTable(tableName, new AlterTableOptions() .changeCompressionAlgorithm(col.getName(), CompressionAlgorithm.SNAPPY) .changeEncoding(col.getName(), Encoding.RLE) .changeDefault(col.getName(), 0)); // Check for new values. table = client.openTable(tableName); col = table.getSchema().getColumns().get(1); assertEquals(CompressionAlgorithm.SNAPPY, col.getCompressionAlgorithm()); assertEquals(Encoding.RLE, col.getEncoding()); assertEquals(0, col.getDefaultValue()); }
KuduSession session = client.newSession(); AlterTableOptions ato = new AlterTableOptions(); PartialRow bLowerBound = BASIC_SCHEMA.newPartialRow(); bLowerBound.addInt("key", 300); session.apply(insert); ato = new AlterTableOptions(); bLowerBound = BASIC_SCHEMA.newPartialRow(); bLowerBound.addInt("key", 200);
.defaultAdminOperationTimeoutMs(harness.DEFAULT_SLEEP) .build()) { AlterTableOptions alter = new AlterTableOptions(); lower = basicSchema.newPartialRow(); upper = basicSchema.newPartialRow();