Search in sources :

Example 1 with NotFoundException

use of io.trino.spi.connector.NotFoundException in project trino by trinodb.

the class KuduMetadata method getTableHandle.

@Override
public KuduTableHandle getTableHandle(ConnectorSession session, SchemaTableName schemaTableName) {
    try {
        KuduTable table = clientSession.openTable(schemaTableName);
        OptionalInt bucketCount = OptionalInt.empty();
        List<HashBucketSchema> bucketSchemas = table.getPartitionSchema().getHashBucketSchemas();
        if (!bucketSchemas.isEmpty()) {
            bucketCount = OptionalInt.of(bucketSchemas.stream().mapToInt(HashBucketSchema::getNumBuckets).reduce(1, Math::multiplyExact));
        }
        return new KuduTableHandle(schemaTableName, table, TupleDomain.all(), Optional.empty(), false, bucketCount, OptionalLong.empty());
    } catch (NotFoundException e) {
        return null;
    }
}
Also used : HashBucketSchema(org.apache.kudu.client.PartitionSchema.HashBucketSchema) NotFoundException(io.trino.spi.connector.NotFoundException) KuduTable(org.apache.kudu.client.KuduTable) OptionalInt(java.util.OptionalInt)

Example 2 with NotFoundException

use of io.trino.spi.connector.NotFoundException in project trino by trinodb.

the class CassandraMetadata method listTableColumns.

@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix) {
    requireNonNull(prefix, "prefix is null");
    ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> columns = ImmutableMap.builder();
    for (SchemaTableName tableName : listTables(session, prefix)) {
        try {
            columns.put(tableName, getTableMetadata(tableName).getColumns());
        } catch (NotFoundException e) {
        // table disappeared during listing operation
        }
    }
    return columns.buildOrThrow();
}
Also used : SchemaNotFoundException(io.trino.spi.connector.SchemaNotFoundException) TableNotFoundException(io.trino.spi.connector.TableNotFoundException) NotFoundException(io.trino.spi.connector.NotFoundException) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toList(java.util.stream.Collectors.toList) SchemaTableName(io.trino.spi.connector.SchemaTableName) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 3 with NotFoundException

use of io.trino.spi.connector.NotFoundException in project trino by trinodb.

the class MongoMetadata method listTableColumns.

@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix) {
    requireNonNull(prefix, "prefix is null");
    ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> columns = ImmutableMap.builder();
    for (SchemaTableName tableName : listTables(session, prefix)) {
        try {
            columns.put(tableName, getTableMetadata(session, tableName).getColumns());
        } catch (NotFoundException e) {
        // table disappeared during listing operation
        }
    }
    return columns.buildOrThrow();
}
Also used : NotFoundException(io.trino.spi.connector.NotFoundException) TableNotFoundException(io.trino.spi.connector.TableNotFoundException) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) SchemaTableName(io.trino.spi.connector.SchemaTableName) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

NotFoundException (io.trino.spi.connector.NotFoundException)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 SchemaTableName (io.trino.spi.connector.SchemaTableName)2 TableNotFoundException (io.trino.spi.connector.TableNotFoundException)2 List (java.util.List)2 Collectors.toList (java.util.stream.Collectors.toList)2 SchemaNotFoundException (io.trino.spi.connector.SchemaNotFoundException)1 OptionalInt (java.util.OptionalInt)1 KuduTable (org.apache.kudu.client.KuduTable)1 HashBucketSchema (org.apache.kudu.client.PartitionSchema.HashBucketSchema)1