Example usage for com.amazonaws.services.glue.model StorageDescriptor setBucketColumns

List of usage examples for com.amazonaws.services.glue.model StorageDescriptor setBucketColumns

Introduction

In this page you can find the example usage for com.amazonaws.services.glue.model StorageDescriptor setBucketColumns.

Prototype


public void setBucketColumns(java.util.Collection<String> bucketColumns) 

Source Link

Document

A list of reducer grouping columns, clustering columns, and bucketing columns in the table.

Usage

From source file:com.facebook.presto.hive.metastore.glue.converter.GlueInputConverter.java

License:Apache License

private static StorageDescriptor convertStorage(Storage storage, List<Column> columns) {
    if (storage.isSkewed()) {
        throw new IllegalArgumentException("Writing to skewed table/partition is not supported");
    }/* ww  w.  j  a  v  a 2s.  co m*/
    SerDeInfo serdeInfo = new SerDeInfo()
            .withSerializationLibrary(storage.getStorageFormat().getSerDeNullable())
            .withParameters(storage.getSerdeParameters());

    StorageDescriptor sd = new StorageDescriptor();
    sd.setLocation(storage.getLocation());
    sd.setColumns(columns.stream().map(GlueInputConverter::convertColumn).collect(toList()));
    sd.setSerdeInfo(serdeInfo);
    sd.setInputFormat(storage.getStorageFormat().getInputFormatNullable());
    sd.setOutputFormat(storage.getStorageFormat().getOutputFormatNullable());
    sd.setParameters(ImmutableMap.of());

    if (storage.getBucketProperty().isPresent()) {
        sd.setNumberOfBuckets(storage.getBucketProperty().get().getBucketCount());
        sd.setBucketColumns(storage.getBucketProperty().get().getBucketedBy());
    }

    return sd;
}