break; case DROP: alterOptions.dropRangePartition(lowerBound, upperBound); break;
/** * Drop the range partition from the table with the specified inclusive lower bound and exclusive * upper bound. The bounds must match exactly, and may not span multiple range partitions. * * If either row is empty, then that end of the range will be unbounded. If a range column is * missing a value, the logical minimum value for that column type will be used as the default. * * Multiple range partitions may be dropped as part of a single alter table transaction by calling * this method multiple times. * * @param lowerBound inclusive lower bound, can be empty but not null * @param upperBound exclusive upper bound, can be empty but not null * @return this instance */ public AlterTableOptions dropRangePartition(PartialRow lowerBound, PartialRow upperBound) { return dropRangePartition(lowerBound, upperBound, RangePartitionBound.INCLUSIVE_BOUND, RangePartitionBound.EXCLUSIVE_BOUND); }
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); } }
break; case DROP: alterOptions.dropRangePartition(lowerBound, upperBound); break;
lower.addInt("c0", 0); upper.addInt("c0", 100); alter.dropRangePartition(lower, upper, RangePartitionBound.INCLUSIVE_BOUND, RangePartitionBound.EXCLUSIVE_BOUND); lower.addInt("c0", 199); upper.addInt("c0", 299); alter.dropRangePartition(lower, upper, RangePartitionBound.EXCLUSIVE_BOUND, RangePartitionBound.INCLUSIVE_BOUND);
PartialRow lower = schema.newPartialRow(); PartialRow upper = schema.newPartialRow(); client.alterTable(tableName, new AlterTableOptions().dropRangePartition(lower, upper)); assertEquals(0, countRowsInTable(table)); options.dropRangePartition(lower, upper); lower.addInt("c0", 50); upper.addInt("c0", 150); client.alterTable(tableName, new AlterTableOptions().dropRangePartition(lower, upper) .addRangePartition(lower, upper)); assertEquals(0, countRowsInTable(table)); options.dropRangePartition(lower, upper); lower.addInt("c0", 50); upper.addInt("c0", 150); options.dropRangePartition(lower, upper); options.dropColumn("c2"); client.alterTable(tableName, options);
bUpperBound = BASIC_SCHEMA.newPartialRow(); bUpperBound.addInt("key", 300); ato.dropRangePartition(bLowerBound, bUpperBound); client.alterTable(tableName, ato);
new AlterTableOptions().dropRangePartition(schema.newPartialRow(), schema.newPartialRow())); fail(); upper.addInt("c0", 150); try { client.alterTable(tableName, new AlterTableOptions().dropRangePartition(lower, upper) .renameTable("foo")); fail(); options.dropRangePartition(lower, upper); options.dropRangePartition(lower, upper); options.dropRangePartition(lower, upper); try { client.alterTable(tableName, options);