Java Code Examples for com.amazonaws.services.glue.model.StorageDescriptor#setLocation()

The following examples show how to use com.amazonaws.services.glue.model.StorageDescriptor#setLocation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestObjects.java    From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 6 votes vote down vote up
public static StorageDescriptor getTestStorageDescriptor() {
  StorageDescriptor sd = new StorageDescriptor();
  List<String> cols = new ArrayList<>();
  cols.add("sampleCols");
  sd.setBucketColumns(cols);
  sd.setColumns(getTestFieldList());
  sd.setParameters(new HashMap<String, String>());
  sd.setSerdeInfo(getTestSerdeInfo());
  sd.setSkewedInfo(getSkewedInfo());
  sd.setSortColumns(new ArrayList<Order>());
  sd.setInputFormat("inputFormat");
  sd.setOutputFormat("outputFormat");
  sd.setLocation("/test-table");
  sd.withSortColumns(new Order().withColumn("foo").withSortOrder(1));
  sd.setCompressed(false);
  sd.setStoredAsSubDirectories(false);
  sd.setNumberOfBuckets(0);
  return sd;
}
 
Example 2
Source File: GlueInputConverter.java    From presto with Apache License 2.0 5 votes vote down vote up
private static StorageDescriptor convertStorage(Storage storage, List<Column> columns)
{
    if (storage.isSkewed()) {
        throw new IllegalArgumentException("Writing to skewed table/partition is not supported");
    }
    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(toImmutableList()));
    sd.setSerdeInfo(serdeInfo);
    sd.setInputFormat(storage.getStorageFormat().getInputFormatNullable());
    sd.setOutputFormat(storage.getStorageFormat().getOutputFormatNullable());
    sd.setParameters(ImmutableMap.of());

    Optional<HiveBucketProperty> bucketProperty = storage.getBucketProperty();
    if (bucketProperty.isPresent()) {
        sd.setNumberOfBuckets(bucketProperty.get().getBucketCount());
        sd.setBucketColumns(bucketProperty.get().getBucketedBy());
        if (!bucketProperty.get().getSortedBy().isEmpty()) {
            sd.setSortColumns(bucketProperty.get().getSortedBy().stream()
                    .map(column -> new Order().withColumn(column.getColumnName()).withSortOrder(column.getOrder().getHiveOrder()))
                    .collect(toImmutableList()));
        }
    }

    return sd;
}