Java Code Examples for io.prestosql.spi.connector.ColumnMetadata#isHidden()

The following examples show how to use io.prestosql.spi.connector.ColumnMetadata#isHidden() . 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: ShowStatsRewrite.java    From presto with Apache License 2.0 6 votes vote down vote up
private List<Expression> buildStatisticsRows(TableMetadata tableMetadata, Map<String, ColumnHandle> columnHandles, Set<String> resultColumns, TableStatistics tableStatistics)
{
    ImmutableList.Builder<Expression> rowsBuilder = ImmutableList.builder();
    for (ColumnMetadata columnMetadata : tableMetadata.getColumns()) {
        if (columnMetadata.isHidden()) {
            continue;
        }
        String columnName = columnMetadata.getName();
        Type columnType = columnMetadata.getType();
        if (!resultColumns.contains(columnName)) {
            continue;
        }
        ColumnHandle columnHandle = columnHandles.get(columnName);
        ColumnStatistics columnStatistics = tableStatistics.getColumnStatistics().get(columnHandle);
        if (columnStatistics != null) {
            rowsBuilder.add(createColumnStatsRow(columnName, columnType, columnStatistics));
        }
        else {
            rowsBuilder.add(createEmptyColumnStatsRow(columnName));
        }
    }
    // Stats for whole table
    rowsBuilder.add(createTableStatsRow(tableStatistics));
    return rowsBuilder.build();
}
 
Example 2
Source File: IcebergMetadata.java    From presto with Apache License 2.0 6 votes vote down vote up
private static Schema toIcebergSchema(List<ColumnMetadata> columns)
{
    List<NestedField> icebergColumns = new ArrayList<>();
    for (ColumnMetadata column : columns) {
        if (!column.isHidden()) {
            int index = icebergColumns.size();
            Type type = toIcebergType(column.getType());
            NestedField field = column.isNullable()
                    ? NestedField.optional(index, column.getName(), type, column.getComment())
                    : NestedField.required(index, column.getName(), type, column.getComment());
            icebergColumns.add(field);
        }
    }
    Schema schema = new Schema(icebergColumns);
    AtomicInteger nextFieldId = new AtomicInteger(1);
    return TypeUtil.assignFreshIds(schema, nextFieldId::getAndIncrement);
}
 
Example 3
Source File: InformationSchemaPageSource.java    From presto with Apache License 2.0 5 votes vote down vote up
private void addColumnsRecords(QualifiedTablePrefix prefix)
{
    for (Map.Entry<SchemaTableName, List<ColumnMetadata>> entry : listTableColumns(session, metadata, accessControl, prefix).entrySet()) {
        SchemaTableName tableName = entry.getKey();
        int ordinalPosition = 1;
        for (ColumnMetadata column : entry.getValue()) {
            if (column.isHidden()) {
                continue;
            }
            addRecord(
                    prefix.getCatalogName(),
                    tableName.getSchemaName(),
                    tableName.getTableName(),
                    column.getName(),
                    ordinalPosition,
                    null,
                    "YES",
                    column.getType().getDisplayName(),
                    column.getComment(),
                    column.getExtraInfo(),
                    column.getComment());
            ordinalPosition++;
            if (isLimitExhausted()) {
                return;
            }
        }
    }
}
 
Example 4
Source File: ColumnJdbcTable.java    From presto with Apache License 2.0 5 votes vote down vote up
private static void addColumnRows(Builder builder, String catalog, SchemaTableName tableName, List<ColumnMetadata> columns)
{
    int ordinalPosition = 1;
    for (ColumnMetadata column : columns) {
        if (column.isHidden()) {
            continue;
        }
        builder.addRow(
                catalog,
                tableName.getSchemaName(),
                tableName.getTableName(),
                column.getName(),
                jdbcDataType(column.getType()),
                column.getType().getDisplayName(),
                columnSize(column.getType()),
                0,
                decimalDigits(column.getType()),
                numPrecRadix(column.getType()),
                DatabaseMetaData.columnNullableUnknown,
                column.getComment(),
                null,
                null,
                null,
                charOctetLength(column.getType()),
                ordinalPosition,
                "",
                null,
                null,
                null,
                null,
                null,
                null);
        ordinalPosition++;
    }
}
 
Example 5
Source File: HiveMetadata.java    From presto with Apache License 2.0 5 votes vote down vote up
private List<HiveColumnHandle> getColumnHandles(ConnectorTableMetadata tableMetadata, Set<String> partitionColumnNames)
{
    validatePartitionColumns(tableMetadata);
    validateBucketColumns(tableMetadata);
    validateColumns(tableMetadata);

    ImmutableList.Builder<HiveColumnHandle> columnHandles = ImmutableList.builder();
    int ordinal = 0;
    for (ColumnMetadata column : tableMetadata.getColumns()) {
        HiveColumnHandle.ColumnType columnType;
        if (partitionColumnNames.contains(column.getName())) {
            columnType = PARTITION_KEY;
        }
        else if (column.isHidden()) {
            columnType = SYNTHESIZED;
        }
        else {
            columnType = REGULAR;
        }
        columnHandles.add(createBaseColumn(
                column.getName(),
                ordinal,
                toHiveType(typeTranslator, column.getType()),
                column.getType(),
                columnType,
                Optional.ofNullable(column.getComment())));
        ordinal++;
    }

    return columnHandles.build();
}
 
Example 6
Source File: ThriftColumnHandle.java    From presto with Apache License 2.0 4 votes vote down vote up
public ThriftColumnHandle(ColumnMetadata columnMetadata)
{
    this(columnMetadata.getName(), columnMetadata.getType(), columnMetadata.getComment(), columnMetadata.isHidden());
}