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

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

Introduction

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

Prototype


public String getLocation() 

Source Link

Document

The physical location of the table.

Usage

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

License:Apache License

private static void setStorageBuilder(StorageDescriptor sd, Storage.Builder storageBuilder) {
    requireNonNull(sd.getSerdeInfo(), "StorageDescriptor SerDeInfo is null");
    SerDeInfo serdeInfo = sd.getSerdeInfo();

    Optional<HiveBucketProperty> bucketProperty = Optional.empty();
    if (sd.getNumberOfBuckets() > 0) {
        if (isNullOrEmpty(sd.getBucketColumns())) {
            throw new PrestoException(HIVE_INVALID_METADATA,
                    "Table/partition metadata has 'numBuckets' set, but 'bucketCols' is not set");
        }/* ww w  .j  a v  a  2  s.c o m*/
        List<SortingColumn> sortedBy = ImmutableList.of();
        if (!isNullOrEmpty(sd.getSortColumns())) {
            sortedBy = sd.getSortColumns().stream()
                    .map(column -> new SortingColumn(column.getColumn(),
                            Order.fromMetastoreApiOrder(column.getSortOrder(), "unknown")))
                    .collect(toImmutableList());
        }
        bucketProperty = Optional
                .of(new HiveBucketProperty(sd.getBucketColumns(), sd.getNumberOfBuckets(), sortedBy));
    }

    storageBuilder
            .setStorageFormat(StorageFormat.createNullable(serdeInfo.getSerializationLibrary(),
                    sd.getInputFormat(), sd.getOutputFormat()))
            .setLocation(nullToEmpty(sd.getLocation())).setBucketProperty(bucketProperty)
            .setSkewed(sd.getSkewedInfo() != null && !isNullOrEmpty(sd.getSkewedInfo().getSkewedColumnNames()))
            .setSerdeParameters(firstNonNull(serdeInfo.getParameters(), ImmutableMap.of())).build();
}