Search in sources :

Example 1 with RangePartition

use of com.facebook.presto.kudu.properties.RangePartition in project presto by prestodb.

the class KuduClientSession method buildCreateTableOptions.

private CreateTableOptions buildCreateTableOptions(Schema schema, Map<String, Object> properties) {
    CreateTableOptions options = new CreateTableOptions();
    RangePartitionDefinition rangePartitionDefinition = null;
    PartitionDesign partitionDesign = KuduTableProperties.getPartitionDesign(properties);
    if (partitionDesign.getHash() != null) {
        for (HashPartitionDefinition partition : partitionDesign.getHash()) {
            options.addHashPartitions(partition.getColumns(), partition.getBuckets());
        }
    }
    if (partitionDesign.getRange() != null) {
        rangePartitionDefinition = partitionDesign.getRange();
        options.setRangePartitionColumns(rangePartitionDefinition.getColumns());
    }
    List<RangePartition> rangePartitions = KuduTableProperties.getRangePartitions(properties);
    if (rangePartitionDefinition != null && !rangePartitions.isEmpty()) {
        for (RangePartition rangePartition : rangePartitions) {
            PartialRow lower = KuduTableProperties.toRangeBoundToPartialRow(schema, rangePartitionDefinition, rangePartition.getLower());
            PartialRow upper = KuduTableProperties.toRangeBoundToPartialRow(schema, rangePartitionDefinition, rangePartition.getUpper());
            options.addRangePartition(lower, upper);
        }
    }
    Optional<Integer> numReplicas = KuduTableProperties.getNumReplicas(properties);
    numReplicas.ifPresent(options::setNumReplicas);
    return options;
}
Also used : RangePartition(com.facebook.presto.kudu.properties.RangePartition) HashPartitionDefinition(com.facebook.presto.kudu.properties.HashPartitionDefinition) PartialRow(org.apache.kudu.client.PartialRow) RangePartitionDefinition(com.facebook.presto.kudu.properties.RangePartitionDefinition) CreateTableOptions(org.apache.kudu.client.CreateTableOptions) PartitionDesign(com.facebook.presto.kudu.properties.PartitionDesign)

Example 2 with RangePartition

use of com.facebook.presto.kudu.properties.RangePartition in project presto by prestodb.

the class RangePartitionProcedures method dropRangePartition.

public void dropRangePartition(String schema, String table, String rangeBounds) {
    SchemaTableName schemaTableName = new SchemaTableName(schema, table);
    RangePartition rangePartition = KuduTableProperties.parseRangePartition(rangeBounds);
    clientSession.dropRangePartition(schemaTableName, rangePartition);
}
Also used : RangePartition(com.facebook.presto.kudu.properties.RangePartition) SchemaTableName(com.facebook.presto.spi.SchemaTableName)

Example 3 with RangePartition

use of com.facebook.presto.kudu.properties.RangePartition in project presto by prestodb.

the class RangePartitionProcedures method addRangePartition.

public void addRangePartition(String schema, String table, String rangeBounds) {
    SchemaTableName schemaTableName = new SchemaTableName(schema, table);
    RangePartition rangePartition = KuduTableProperties.parseRangePartition(rangeBounds);
    clientSession.addRangePartition(schemaTableName, rangePartition);
}
Also used : RangePartition(com.facebook.presto.kudu.properties.RangePartition) SchemaTableName(com.facebook.presto.spi.SchemaTableName)

Aggregations

RangePartition (com.facebook.presto.kudu.properties.RangePartition)3 SchemaTableName (com.facebook.presto.spi.SchemaTableName)2 HashPartitionDefinition (com.facebook.presto.kudu.properties.HashPartitionDefinition)1 PartitionDesign (com.facebook.presto.kudu.properties.PartitionDesign)1 RangePartitionDefinition (com.facebook.presto.kudu.properties.RangePartitionDefinition)1 CreateTableOptions (org.apache.kudu.client.CreateTableOptions)1 PartialRow (org.apache.kudu.client.PartialRow)1