Java Code Examples for io.prestosql.spi.connector.ColumnMetadata

The following examples show how to use io.prestosql.spi.connector.ColumnMetadata. These examples are extracted from open source projects. 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 Project: presto   Source File: TestRaptorConnector.java    License: Apache License 2.0 6 votes vote down vote up
private long createTable(String name)
{
    ConnectorTransactionHandle transaction = connector.beginTransaction(READ_COMMITTED, false);
    connector.getMetadata(transaction).createTable(
            SESSION,
            new ConnectorTableMetadata(
                    new SchemaTableName("test", name),
                    ImmutableList.of(new ColumnMetadata("id", BIGINT))),
            false);
    connector.commit(transaction);

    transaction = connector.beginTransaction(READ_COMMITTED, false);
    ConnectorTableHandle tableHandle = getTableHandle(connector.getMetadata(transaction), name);
    connector.commit(transaction);
    return ((RaptorTableHandle) tableHandle).getTableId();
}
 
Example 2
Source Project: pulsar   Source File: PulsarMetadata.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Convert pulsar schema into presto table metadata.
 */
static List<ColumnMetadata> getPulsarColumns(TopicName topicName,
                                             SchemaInfo schemaInfo,
                                             boolean withInternalColumns,
                                             PulsarColumnHandle.HandleKeyValueType handleKeyValueType) {
    SchemaType schemaType = schemaInfo.getType();
    if (schemaType.isStruct()) {
        return getPulsarColumnsFromStructSchema(topicName, schemaInfo, withInternalColumns, handleKeyValueType);
    } else if (schemaType.isPrimitive()) {
        return getPulsarColumnsFromPrimitiveSchema(topicName, schemaInfo, withInternalColumns, handleKeyValueType);
    } else if (schemaType.equals(SchemaType.KEY_VALUE)) {
        return getPulsarColumnsFromKeyValueSchema(topicName, schemaInfo, withInternalColumns);
    } else {
        throw new IllegalArgumentException("Unsupported schema : " + schemaInfo);
    }
}
 
Example 3
Source Project: presto   Source File: TestPrometheusIntegrationTests2.java    License: Apache License 2.0 6 votes vote down vote up
@Test(dependsOnMethods = "testRetrieveUpValue")
public void testGetTableMetadata()
        throws Exception
{
    PrometheusMetadata metadata = new PrometheusMetadata(client);
    // known table
    ConnectorTableMetadata tableMetadata = metadata.getTableMetadata(SESSION, RUNTIME_DETERMINED_TABLE_HANDLE);
    assertEquals(tableMetadata.getTable(), new SchemaTableName("default", "up"));
    assertEquals(tableMetadata.getColumns(), ImmutableList.of(
            new ColumnMetadata("labels", varcharMapType),
            new ColumnMetadata("timestamp", TimestampType.TIMESTAMP),
            new ColumnMetadata("value", DOUBLE)));

    // unknown tables should produce null
    assertNull(metadata.getTableMetadata(SESSION, new PrometheusTableHandle("unknown", "unknown")));
    assertNull(metadata.getTableMetadata(SESSION, new PrometheusTableHandle("default", "unknown")));
    assertNull(metadata.getTableMetadata(SESSION, new PrometheusTableHandle("unknown", "numbers")));
}
 
Example 4
Source Project: presto   Source File: TestRaptorMetadata.java    License: Apache License 2.0 6 votes vote down vote up
private static void assertTableEqual(ConnectorTableMetadata actual, ConnectorTableMetadata expected)
{
    assertEquals(actual.getTable(), expected.getTable());

    List<ColumnMetadata> actualColumns = actual.getColumns().stream()
            .filter(columnMetadata -> !columnMetadata.isHidden())
            .collect(Collectors.toList());

    List<ColumnMetadata> expectedColumns = expected.getColumns();
    assertEquals(actualColumns.size(), expectedColumns.size());
    for (int i = 0; i < actualColumns.size(); i++) {
        ColumnMetadata actualColumn = actualColumns.get(i);
        ColumnMetadata expectedColumn = expectedColumns.get(i);
        assertEquals(actualColumn.getName(), expectedColumn.getName());
        assertEquals(actualColumn.getType(), expectedColumn.getType());
    }
    assertEquals(actual.getProperties(), expected.getProperties());
}
 
Example 5
Source Project: presto-hbase-connector   Source File: HBaseTable.java    License: Apache License 2.0 6 votes vote down vote up
public HBaseTable(String schemaName, HTableDescriptor tabDesc, HBaseConfig config) {
    this.hTableDescriptor = Objects.requireNonNull(tabDesc, "tabDesc is null");
    Objects.requireNonNull(schemaName, "schemaName is null");
    ImmutableList<ColumnMetadata> tableMeta = null;
    try {
        String tableName = tabDesc.getNameAsString() != null && tabDesc.getNameAsString().contains(":") ?
                tabDesc.getNameAsString().split(":")[1] : tabDesc.getNameAsString();
        tableMeta = Utils.getColumnMetaFromJson(schemaName, tableName, config.getMetaDir());
        if (tableMeta == null || tableMeta.size() <= 0) {
            logger.error("OOPS! Table meta info cannot be NULL, table name=" + tabDesc.getNameAsString());
            throw new Exception("Cannot find meta info of table " + tabDesc.getNameAsString() + ".");
        }
    } catch (Exception e) {
        logger.error(e, e.getMessage());
    }
    this.columnsMetadata = tableMeta;
}
 
Example 6
Source Project: presto   Source File: MockConnectorFactory.java    License: Apache License 2.0 6 votes vote down vote up
private MockConnector(
        ConnectorContext context,
        Function<ConnectorSession, List<String>> listSchemaNames,
        BiFunction<ConnectorSession, String, List<SchemaTableName>> listTables,
        BiFunction<ConnectorSession, SchemaTablePrefix, Map<SchemaTableName, ConnectorViewDefinition>> getViews,
        BiFunction<ConnectorSession, SchemaTableName, ConnectorTableHandle> getTableHandle,
        Function<SchemaTableName, List<ColumnMetadata>> getColumns,
        ApplyProjection applyProjection,
        BiFunction<ConnectorSession, SchemaTableName, Optional<ConnectorNewTableLayout>> getInsertLayout,
        BiFunction<ConnectorSession, ConnectorTableMetadata, Optional<ConnectorNewTableLayout>> getNewTableLayout,
        Supplier<Iterable<EventListener>> eventListeners,
        ListRoleGrants roleGrants)
{
    this.context = requireNonNull(context, "context is null");
    this.listSchemaNames = requireNonNull(listSchemaNames, "listSchemaNames is null");
    this.listTables = requireNonNull(listTables, "listTables is null");
    this.getViews = requireNonNull(getViews, "getViews is null");
    this.getTableHandle = requireNonNull(getTableHandle, "getTableHandle is null");
    this.getColumns = requireNonNull(getColumns, "getColumns is null");
    this.applyProjection = requireNonNull(applyProjection, "applyProjection is null");
    this.getInsertLayout = requireNonNull(getInsertLayout, "getInsertLayout is null");
    this.getNewTableLayout = requireNonNull(getNewTableLayout, "getNewTableLayout is null");
    this.eventListeners = requireNonNull(eventListeners, "eventListeners is null");
    this.roleGrants = requireNonNull(roleGrants, "roleGrants is null");
}
 
Example 7
Source Project: presto   Source File: RedisMetadata.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
private ConnectorTableMetadata getTableMetadata(SchemaTableName schemaTableName)
{
    RedisTableDescription table = getDefinedTables().get(schemaTableName);
    if (table == null) {
        return null;
    }

    ImmutableList.Builder<ColumnMetadata> builder = ImmutableList.builder();

    appendFields(builder, table.getKey());
    appendFields(builder, table.getValue());

    for (RedisInternalFieldDescription fieldDescription : RedisInternalFieldDescription.values()) {
        builder.add(fieldDescription.getColumnMetadata(hideInternalColumns));
    }

    return new ConnectorTableMetadata(schemaTableName, builder.build());
}
 
Example 8
Source Project: presto   Source File: TestTypeConversions.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testConvertTwoLevelsRecordColumn()
{
    BigQueryColumnHandle column = new BigQueryColumnHandle("rec", BigQueryType.RECORD, Field.Mode.NULLABLE, ImmutableList.of(
            new BigQueryColumnHandle("sub_rec", BigQueryType.RECORD, Field.Mode.NULLABLE, ImmutableList.of(
                    new BigQueryColumnHandle("sub_sub_s", BigQueryType.STRING, Field.Mode.NULLABLE, ImmutableList.of(), null),
                    new BigQueryColumnHandle("sub_sub_i", BigQueryType.INTEGER, Field.Mode.NULLABLE, ImmutableList.of(), null)
            ), null),
            new BigQueryColumnHandle("sub_s", BigQueryType.STRING, Field.Mode.NULLABLE, ImmutableList.of(), null),
            new BigQueryColumnHandle("sub_i", BigQueryType.INTEGER, Field.Mode.NULLABLE, ImmutableList.of(), null)
    ), null);
    ColumnMetadata metadata = column.getColumnMetadata();
    RowType targetType = RowType.rowType(
            RowType.field("sub_rec", RowType.rowType(
                    RowType.field("sub_sub_s", VarcharType.VARCHAR),
                    RowType.field("sub_sub_i", BigintType.BIGINT))),
            RowType.field("sub_s", VarcharType.VARCHAR),
            RowType.field("sub_i", BigintType.BIGINT));
    assertThat(metadata.getType()).isEqualTo(targetType);
}
 
Example 9
Source Project: presto   Source File: BaseJdbcClient.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void addColumn(ConnectorSession session, JdbcTableHandle handle, ColumnMetadata column)
{
    try (Connection connection = connectionFactory.openConnection(JdbcIdentity.from(session))) {
        String columnName = column.getName();
        if (connection.getMetaData().storesUpperCaseIdentifiers()) {
            columnName = columnName.toUpperCase(ENGLISH);
        }
        String sql = format(
                "ALTER TABLE %s ADD %s",
                quoted(handle.getCatalogName(), handle.getSchemaName(), handle.getTableName()),
                getColumnSql(session, column, columnName));
        execute(connection, sql);
    }
    catch (SQLException e) {
        throw new PrestoException(JDBC_ERROR, e);
    }
}
 
Example 10
Source Project: presto   Source File: ManifestsTable.java    License: Apache License 2.0 6 votes vote down vote up
public ManifestsTable(SchemaTableName tableName, Table icebergTable, Optional<Long> snapshotId)
{
    this.icebergTable = requireNonNull(icebergTable, "icebergTable is null");

    tableMetadata = new ConnectorTableMetadata(
            tableName,
            ImmutableList.<ColumnMetadata>builder()
                    .add(new ColumnMetadata("path", VARCHAR))
                    .add(new ColumnMetadata("length", BIGINT))
                    .add(new ColumnMetadata("partition_spec_id", INTEGER))
                    .add(new ColumnMetadata("added_snapshot_id", BIGINT))
                    .add(new ColumnMetadata("added_data_files_count", INTEGER))
                    .add(new ColumnMetadata("existing_data_files_count", INTEGER))
                    .add(new ColumnMetadata("deleted_data_files_count", INTEGER))
                    .add(new ColumnMetadata("partitions", RowType.rowType(
                            RowType.field("contains_null", BOOLEAN),
                            RowType.field("lower_bound", VARCHAR),
                            RowType.field("upper_bound", VARCHAR))))
                    .build());
    this.snapshotId = requireNonNull(snapshotId, "snapshotId is null");
}
 
Example 11
Source Project: presto   Source File: KuduMetadata.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix)
{
    requireNonNull(prefix, "SchemaTablePrefix is null");

    List<SchemaTableName> tables;
    if (prefix.getTable().isEmpty()) {
        tables = listTables(session, prefix.getSchema());
    }
    else {
        tables = ImmutableList.of(prefix.toSchemaTableName());
    }

    ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> columns = ImmutableMap.builder();
    for (SchemaTableName tableName : tables) {
        KuduTableHandle tableHandle = getTableHandle(session, tableName);
        if (tableHandle != null) {
            ConnectorTableMetadata tableMetadata = getTableMetadata(tableHandle);
            columns.put(tableName, tableMetadata.getColumns());
        }
    }
    return columns.build();
}
 
Example 12
Source Project: presto   Source File: SystemPageSourceProvider.java    License: Apache License 2.0 6 votes vote down vote up
private static RecordSet toRecordSet(ConnectorTransactionHandle sourceTransaction, SystemTable table, ConnectorSession session, TupleDomain<Integer> constraint)
{
    return new RecordSet()
    {
        private final List<Type> types = table.getTableMetadata().getColumns().stream()
                .map(ColumnMetadata::getType)
                .collect(toImmutableList());

        @Override
        public List<Type> getColumnTypes()
        {
            return types;
        }

        @Override
        public RecordCursor cursor()
        {
            return table.cursor(sourceTransaction, session, constraint);
        }
    };
}
 
Example 13
Source Project: presto   Source File: ElasticsearchMetadata.java    License: Apache License 2.0 6 votes vote down vote up
private List<ColumnMetadata> makeColumnMetadata(List<IndexMetadata.Field> fields)
{
    ImmutableList.Builder<ColumnMetadata> result = ImmutableList.builder();

    for (BuiltinColumns builtinColumn : BuiltinColumns.values()) {
        result.add(builtinColumn.getMetadata());
    }

    for (IndexMetadata.Field field : fields) {
        result.add(ColumnMetadata.builder()
                .setName(field.getName())
                .setType(toPrestoType(field))
                .build());
    }
    return result.build();
}
 
Example 14
Source Project: presto   Source File: PrometheusTable.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public PrometheusTable(
        @JsonProperty("name") String name,
        @JsonProperty("columns") List<PrometheusColumn> columns)
{
    checkArgument(!isNullOrEmpty(name), "name is null or is empty");
    this.name = requireNonNull(name, "name is null");
    this.columns = columns;
    ImmutableList.Builder<ColumnMetadata> columnsMetadata = ImmutableList.builder();
    for (PrometheusColumn column : this.columns) {
        columnsMetadata.add(new ColumnMetadata(column.getName(), column.getType()));
    }
    this.columnsMetadata = columnsMetadata.build();
}
 
Example 15
Source Project: presto   Source File: SystemTableAwareAccessControl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<ColumnMetadata> filterColumns(ConnectorSecurityContext context, SchemaTableName tableName, List<ColumnMetadata> columns)
{
    Optional<SchemaTableName> sourceTableName = getSourceTableNameFromSystemTable(tableName);
    if (sourceTableName.isPresent()) {
        return filterColumns(context, sourceTableName.get(), columns);
    }
    return delegate.filterColumns(context, tableName, columns);
}
 
Example 16
Source Project: presto   Source File: MetadataUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static ColumnMetadata findColumnMetadata(ConnectorTableMetadata tableMetadata, String columnName)
{
    for (ColumnMetadata columnMetadata : tableMetadata.getColumns()) {
        if (columnName.equals(columnMetadata.getName())) {
            return columnMetadata;
        }
    }
    return null;
}
 
Example 17
Source Project: presto   Source File: ColumnJdbcTable.java    License: 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 18
Source Project: presto   Source File: KuduClientSession.java    License: Apache License 2.0 5 votes vote down vote up
private ColumnSchema toColumnSchema(ColumnMetadata columnMetadata)
{
    String name = columnMetadata.getName();
    ColumnDesign design = KuduTableProperties.getColumnDesign(columnMetadata.getProperties());
    Type ktype = TypeHelper.toKuduClientType(columnMetadata.getType());
    ColumnSchema.ColumnSchemaBuilder builder = new ColumnSchema.ColumnSchemaBuilder(name, ktype);
    builder.key(design.isPrimaryKey()).nullable(design.isNullable());
    setEncoding(name, builder, design);
    setCompression(name, builder, design);
    setTypeAttributes(columnMetadata, builder);
    return builder.build();
}
 
Example 19
Source Project: presto   Source File: TestPrometheusTable.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testColumnMetadata()
{
    assertEquals(prometheusTable.getColumnsMetadata(), ImmutableList.of(
            new ColumnMetadata("labels", varcharMapType),
            new ColumnMetadata("timestamp", TimestampType.TIMESTAMP),
            new ColumnMetadata("value", DoubleType.DOUBLE)));
}
 
Example 20
Source Project: presto   Source File: HiveMetadata.java    License: Apache License 2.0 5 votes vote down vote up
private TableStatisticsMetadata getStatisticsCollectionMetadata(List<ColumnMetadata> columns, List<String> partitionedBy, Optional<Set<String>> analyzeColumns, boolean includeRowCount)
{
    Set<ColumnStatisticMetadata> columnStatistics = columns.stream()
            .filter(column -> !partitionedBy.contains(column.getName()))
            .filter(column -> !column.isHidden())
            .filter(column -> analyzeColumns.isEmpty() || analyzeColumns.get().contains(column.getName()))
            .map(this::getColumnStatisticMetadata)
            .flatMap(List::stream)
            .collect(toImmutableSet());

    Set<TableStatisticType> tableStatistics = includeRowCount ? ImmutableSet.of(ROW_COUNT) : ImmutableSet.of();
    return new TableStatisticsMetadata(columnStatistics, tableStatistics, partitionedBy);
}
 
Example 21
Source Project: presto   Source File: HiveMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Optional<ConnectorNewTableLayout> getNewTableLayout(ConnectorSession session, ConnectorTableMetadata tableMetadata)
{
    validatePartitionColumns(tableMetadata);
    validateBucketColumns(tableMetadata);
    validateColumns(tableMetadata);
    Optional<HiveBucketProperty> bucketProperty = getBucketProperty(tableMetadata.getProperties());
    if (bucketProperty.isEmpty()) {
        // return preferred layout which is partitioned by partition columns
        List<String> partitionedBy = getPartitionedBy(tableMetadata.getProperties());
        if (partitionedBy.isEmpty()) {
            return Optional.empty();
        }

        return Optional.of(new ConnectorNewTableLayout(partitionedBy));
    }
    if (!bucketProperty.get().getSortedBy().isEmpty() && !isSortedWritingEnabled(session)) {
        throw new PrestoException(NOT_SUPPORTED, "Writing to bucketed sorted Hive tables is disabled");
    }

    List<String> bucketedBy = bucketProperty.get().getBucketedBy();
    Map<String, HiveType> hiveTypeMap = tableMetadata.getColumns().stream()
            .collect(toMap(ColumnMetadata::getName, column -> toHiveType(typeTranslator, column.getType())));
    return Optional.of(new ConnectorNewTableLayout(
            new HivePartitioningHandle(
                    bucketProperty.get().getBucketingVersion(),
                    bucketProperty.get().getBucketCount(),
                    bucketedBy.stream()
                            .map(hiveTypeMap::get)
                            .collect(toList()),
                    OptionalInt.of(bucketProperty.get().getBucketCount())),
            bucketedBy));
}
 
Example 22
Source Project: presto   Source File: ThriftTableMetadata.java    License: Apache License 2.0 5 votes vote down vote up
public ThriftTableMetadata(SchemaTableName schemaTableName, List<ColumnMetadata> columns, Optional<String> comment, List<Set<String>> indexableKeys)
{
    this.schemaTableName = requireNonNull(schemaTableName, "schemaTableName is null");
    this.columns = ImmutableList.copyOf(requireNonNull(columns, "columns is null"));
    this.comment = requireNonNull(comment, "comment is null");
    this.indexableKeys = deepImmutableCopy(requireNonNull(indexableKeys, "indexableKeys is null"));
}
 
Example 23
Source Project: presto   Source File: TestShowQueries.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeClass
public void init()
{
    LocalQueryRunner queryRunner = LocalQueryRunner.create(testSessionBuilder()
            .setCatalog("local")
            .setSchema("default")
            .build());
    queryRunner.createCatalog(
            "mock",
            MockConnectorFactory.builder()
                    .withGetColumns(schemaTableName ->
                            ImmutableList.of(
                                    ColumnMetadata.builder()
                                            .setName("colaa")
                                            .setType(BIGINT)
                                            .build(),
                                    ColumnMetadata.builder()
                                            .setName("cola_")
                                            .setType(BIGINT)
                                            .build(),
                                    ColumnMetadata.builder()
                                            .setName("colabc")
                                            .setType(BIGINT)
                                            .build()))
                    .withListTables((session, schemaName) -> ImmutableList.of(new SchemaTableName("mockSchema", "mockTable")))
                    .build(),
            ImmutableMap.of());
    assertions = new QueryAssertions(queryRunner);
}
 
Example 24
Source Project: presto   Source File: IcebergMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle)
{
    IcebergColumnHandle column = (IcebergColumnHandle) columnHandle;
    return ColumnMetadata.builder()
            .setName(column.getName())
            .setType(column.getType())
            .setComment(column.getComment())
            .build();
}
 
Example 25
Source Project: presto   Source File: TestingMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle)
{
    ImmutableMap.Builder<String, ColumnHandle> builder = ImmutableMap.builder();
    int index = 0;
    for (ColumnMetadata columnMetadata : getTableMetadata(session, tableHandle).getColumns()) {
        builder.put(columnMetadata.getName(), new TestingColumnHandle(columnMetadata.getName(), index, columnMetadata.getType()));
        index++;
    }
    return builder.build();
}
 
Example 26
Source Project: presto   Source File: TestExampleTable.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testColumnMetadata()
{
    assertEquals(exampleTable.getColumnsMetadata(), ImmutableList.of(
            new ColumnMetadata("a", createUnboundedVarcharType()),
            new ColumnMetadata("b", BIGINT)));
}
 
Example 27
Source Project: presto   Source File: TestRaptorMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testListTableColumnsFiltering()
{
    metadata.createTable(SESSION, getOrdersTable(), false);
    Map<SchemaTableName, List<ColumnMetadata>> filterCatalog = metadata.listTableColumns(SESSION, new SchemaTablePrefix());
    Map<SchemaTableName, List<ColumnMetadata>> filterSchema = metadata.listTableColumns(SESSION, new SchemaTablePrefix("test"));
    Map<SchemaTableName, List<ColumnMetadata>> filterTable = metadata.listTableColumns(SESSION, new SchemaTablePrefix("test", "orders"));
    assertEquals(filterCatalog, filterSchema);
    assertEquals(filterCatalog, filterTable);
}
 
Example 28
Source Project: presto   Source File: RedisTableFieldDescription.java    License: Apache License 2.0 5 votes vote down vote up
ColumnMetadata getColumnMetadata()
{
    return ColumnMetadata.builder()
            .setName(getName())
            .setType(getType())
            .setComment(Optional.ofNullable(getComment()))
            .setHidden(isHidden())
            .build();
}
 
Example 29
Source Project: presto   Source File: PinotMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ColumnMetadata getColumnMetadata(
        ConnectorSession session,
        ConnectorTableHandle tableHandle,
        ColumnHandle columnHandle)
{
    return ((PinotColumnHandle) columnHandle).getColumnMetadata();
}
 
Example 30
Source Project: presto   Source File: BlackHoleMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix)
{
    return tables.values().stream()
            .filter(table -> prefix.matches(table.toSchemaTableName()))
            .collect(toMap(BlackHoleTableHandle::toSchemaTableName, handle -> handle.toTableMetadata().getColumns()));
}