Java Code Examples for com.facebook.presto.spi.ColumnMetadata#getType()

The following examples show how to use com.facebook.presto.spi.ColumnMetadata#getType() . 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: Elasticsearch2Client.java    From presto-connectors with Apache License 2.0 6 votes vote down vote up
private static XContentBuilder getMapping(List<ColumnMetadata> columns)
{
    XContentBuilder mapping = null;
    try {
        mapping = jsonBuilder()
                .startObject().startObject("properties");
        for (ColumnMetadata columnMetadata : columns) {
            String columnName = columnMetadata.getName();
            Type type = columnMetadata.getType();
            if ("@timestamp".equals(columnName)) {    //break @timestamp field
                continue;
            }
            buildFieldType(mapping.startObject(columnName), type).endObject();
        }
        mapping.endObject().endObject();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    return mapping;
}
 
Example 2
Source File: Elasticsearch6Client.java    From presto-connectors with Apache License 2.0 6 votes vote down vote up
private static XContentBuilder getMapping(List<ColumnMetadata> columns)
{
    XContentBuilder mapping = null;
    try {
        mapping = jsonBuilder()
                .startObject().startObject("properties");
        for (ColumnMetadata columnMetadata : columns) {
            String columnName = columnMetadata.getName();
            Type type = columnMetadata.getType();
            if ("@timestamp".equals(columnName)) {    //break @timestamp field
                continue;
            }
            buildFieldType(mapping.startObject(columnName), type).endObject();
        }
        mapping.endObject().endObject();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    return mapping;
}
 
Example 3
Source File: Elasticsearch5Client.java    From presto-connectors with Apache License 2.0 6 votes vote down vote up
private static XContentBuilder getMapping(List<ColumnMetadata> columns)
{
    XContentBuilder mapping = null;
    try {
        mapping = jsonBuilder()
                .startObject().startObject("properties");
        for (ColumnMetadata columnMetadata : columns) {
            String columnName = columnMetadata.getName();
            Type type = columnMetadata.getType();
            if ("@timestamp".equals(columnName)) {    //break @timestamp field
                continue;
            }
            buildFieldType(mapping.startObject(columnName), type).endObject();
        }
        mapping.endObject().endObject();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    return mapping;
}
 
Example 4
Source File: NativeKuduClientSession.java    From presto-kudu with Apache License 2.0 5 votes vote down vote up
private void setTypeAttributes(ColumnMetadata columnMetadata, ColumnSchema.ColumnSchemaBuilder builder) {
    if (columnMetadata.getType() instanceof DecimalType) {
        DecimalType type = (DecimalType) columnMetadata.getType();
        ColumnTypeAttributes attributes = new ColumnTypeAttributes.ColumnTypeAttributesBuilder()
                .precision(type.getPrecision())
                .scale(type.getScale()).build();
        builder.typeAttributes(attributes);
    }
}