Search in sources :

Example 1 with TrinoThriftTableMetadata

use of io.trino.plugin.thrift.api.TrinoThriftTableMetadata in project trino by trinodb.

the class ThriftTpchService method getTableMetadata.

@Override
public final TrinoThriftNullableTableMetadata getTableMetadata(TrinoThriftSchemaTableName schemaTableName) {
    String schemaName = schemaTableName.getSchemaName();
    String tableName = schemaTableName.getTableName();
    if (!SCHEMAS.contains(schemaName) || TpchTable.getTables().stream().noneMatch(table -> table.getTableName().equals(tableName))) {
        return new TrinoThriftNullableTableMetadata(null);
    }
    TpchTable<?> tpchTable = TpchTable.getTable(schemaTableName.getTableName());
    List<TrinoThriftColumnMetadata> columns = new ArrayList<>();
    for (TpchColumn<? extends TpchEntity> column : tpchTable.getColumns()) {
        columns.add(new TrinoThriftColumnMetadata(column.getSimplifiedColumnName(), getTypeString(column), null, false));
    }
    List<Set<String>> indexableKeys = getIndexableKeys(schemaName, tableName);
    return new TrinoThriftNullableTableMetadata(new TrinoThriftTableMetadata(schemaTableName, columns, null, !indexableKeys.isEmpty() ? indexableKeys : null));
}
Also used : MoreExecutors.listeningDecorator(com.google.common.util.concurrent.MoreExecutors.listeningDecorator) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) TrinoThriftTupleDomain(io.trino.plugin.thrift.api.TrinoThriftTupleDomain) SplitInfo.normalSplit(io.trino.plugin.thrift.server.SplitInfo.normalSplit) Type(io.trino.spi.type.Type) Page(io.trino.spi.Page) TpchRecordSet.createTpchRecordSet(io.trino.plugin.tpch.TpchRecordSet.createTpchRecordSet) DEFAULT_MAX_PAGE_SIZE_IN_BYTES(io.trino.spi.block.PageBuilderStatus.DEFAULT_MAX_PAGE_SIZE_IN_BYTES) DecimalTypeMapping(io.trino.plugin.tpch.DecimalTypeMapping) TrinoThriftServiceException(io.trino.plugin.thrift.api.TrinoThriftServiceException) ArrayList(java.util.ArrayList) PreDestroy(javax.annotation.PreDestroy) TrinoThriftBlock.fromBlock(io.trino.plugin.thrift.api.TrinoThriftBlock.fromBlock) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) ImmutableList(com.google.common.collect.ImmutableList) TrinoThriftId(io.trino.plugin.thrift.api.TrinoThriftId) RecordPageSource(io.trino.spi.connector.RecordPageSource) TrinoThriftService(io.trino.plugin.thrift.api.TrinoThriftService) TrinoThriftNullableToken(io.trino.plugin.thrift.api.TrinoThriftNullableToken) ConnectorPageSource(io.trino.spi.connector.ConnectorPageSource) TrinoThriftSplit(io.trino.plugin.thrift.api.TrinoThriftSplit) Nullable(javax.annotation.Nullable) TrinoThriftBlock(io.trino.plugin.thrift.api.TrinoThriftBlock) TpchEntity(io.trino.tpch.TpchEntity) TpchTable(io.trino.tpch.TpchTable) TrinoThriftPageResult(io.trino.plugin.thrift.api.TrinoThriftPageResult) Set(java.util.Set) TrinoThriftSplitBatch(io.trino.plugin.thrift.api.TrinoThriftSplitBatch) TrinoThriftNullableTableMetadata(io.trino.plugin.thrift.api.TrinoThriftNullableTableMetadata) Math.min(java.lang.Math.min) TupleDomain(io.trino.spi.predicate.TupleDomain) Threads.threadsNamed(io.airlift.concurrent.Threads.threadsNamed) Ints(com.google.common.primitives.Ints) TpchMetadata.getTrinoType(io.trino.plugin.tpch.TpchMetadata.getTrinoType) Executors.newFixedThreadPool(java.util.concurrent.Executors.newFixedThreadPool) Preconditions.checkState(com.google.common.base.Preconditions.checkState) JsonCodec.jsonCodec(io.airlift.json.JsonCodec.jsonCodec) TpchColumn(io.trino.tpch.TpchColumn) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) TrinoThriftSchemaTableName(io.trino.plugin.thrift.api.TrinoThriftSchemaTableName) Closeable(java.io.Closeable) TrinoThriftNullableColumnSet(io.trino.plugin.thrift.api.TrinoThriftNullableColumnSet) TrinoThriftNullableSchemaName(io.trino.plugin.thrift.api.TrinoThriftNullableSchemaName) TrinoThriftColumnMetadata(io.trino.plugin.thrift.api.TrinoThriftColumnMetadata) TrinoThriftTableMetadata(io.trino.plugin.thrift.api.TrinoThriftTableMetadata) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) JsonCodec(io.airlift.json.JsonCodec) TpchRecordSet.createTpchRecordSet(io.trino.plugin.tpch.TpchRecordSet.createTpchRecordSet) Set(java.util.Set) TrinoThriftNullableColumnSet(io.trino.plugin.thrift.api.TrinoThriftNullableColumnSet) TrinoThriftColumnMetadata(io.trino.plugin.thrift.api.TrinoThriftColumnMetadata) ArrayList(java.util.ArrayList) TrinoThriftNullableTableMetadata(io.trino.plugin.thrift.api.TrinoThriftNullableTableMetadata) TrinoThriftTableMetadata(io.trino.plugin.thrift.api.TrinoThriftTableMetadata)

Aggregations

Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 ImmutableList (com.google.common.collect.ImmutableList)1 Ints (com.google.common.primitives.Ints)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 MoreExecutors.listeningDecorator (com.google.common.util.concurrent.MoreExecutors.listeningDecorator)1 Threads.threadsNamed (io.airlift.concurrent.Threads.threadsNamed)1 JsonCodec (io.airlift.json.JsonCodec)1 JsonCodec.jsonCodec (io.airlift.json.JsonCodec.jsonCodec)1 TrinoThriftBlock (io.trino.plugin.thrift.api.TrinoThriftBlock)1 TrinoThriftBlock.fromBlock (io.trino.plugin.thrift.api.TrinoThriftBlock.fromBlock)1 TrinoThriftColumnMetadata (io.trino.plugin.thrift.api.TrinoThriftColumnMetadata)1 TrinoThriftId (io.trino.plugin.thrift.api.TrinoThriftId)1 TrinoThriftNullableColumnSet (io.trino.plugin.thrift.api.TrinoThriftNullableColumnSet)1 TrinoThriftNullableSchemaName (io.trino.plugin.thrift.api.TrinoThriftNullableSchemaName)1 TrinoThriftNullableTableMetadata (io.trino.plugin.thrift.api.TrinoThriftNullableTableMetadata)1 TrinoThriftNullableToken (io.trino.plugin.thrift.api.TrinoThriftNullableToken)1 TrinoThriftPageResult (io.trino.plugin.thrift.api.TrinoThriftPageResult)1 TrinoThriftSchemaTableName (io.trino.plugin.thrift.api.TrinoThriftSchemaTableName)1