use of com.facebook.presto.kudu.properties.HashPartitionDefinition 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;
}
Aggregations