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

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

Introduction

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

Prototype


public java.util.List<Column> getColumns() 

Source Link

Document

A list of the Columns in the table.

Usage

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

License:Apache License

public static Table convertTable(com.amazonaws.services.glue.model.Table glueTable, String dbName) {
    requireNonNull(glueTable.getStorageDescriptor(), "Table StorageDescriptor is null");
    StorageDescriptor sd = glueTable.getStorageDescriptor();

    Table.Builder tableBuilder = Table.builder().setDatabaseName(dbName).setTableName(glueTable.getName())
            .setOwner(nullToEmpty(glueTable.getOwner())).setTableType(glueTable.getTableType())
            .setDataColumns(/*  w  ww.ja va 2 s  .  c o m*/
                    sd.getColumns().stream().map(GlueToPrestoConverter::convertColumn).collect(toList()))
            .setParameters(firstNonNull(glueTable.getParameters(), ImmutableMap.of()))
            .setViewOriginalText(Optional.ofNullable(glueTable.getViewOriginalText()))
            .setViewExpandedText(Optional.ofNullable(glueTable.getViewExpandedText()));

    if (glueTable.getPartitionKeys() != null) {
        tableBuilder.setPartitionColumns(glueTable.getPartitionKeys().stream()
                .map(GlueToPrestoConverter::convertColumn).collect(toList()));
    } else {
        tableBuilder.setPartitionColumns(new ArrayList<>());
    }

    setStorageBuilder(sd, tableBuilder.getStorageBuilder());
    return tableBuilder.build();
}

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

License:Apache License

public static Partition convertPartition(com.amazonaws.services.glue.model.Partition gluePartition) {
    requireNonNull(gluePartition.getStorageDescriptor(), "Partition StorageDescriptor is null");
    StorageDescriptor sd = gluePartition.getStorageDescriptor();

    Partition.Builder partitionBuilder = Partition.builder().setDatabaseName(gluePartition.getDatabaseName())
            .setTableName(gluePartition.getTableName()).setValues(gluePartition.getValues())
            .setColumns(sd.getColumns().stream().map(GlueToPrestoConverter::convertColumn).collect(toList()))
            .setParameters(firstNonNull(gluePartition.getParameters(), ImmutableMap.of()));

    setStorageBuilder(sd, partitionBuilder.getStorageBuilder());
    return partitionBuilder.build();
}