com.facebook.presto.spi.TableNotFoundException Java Examples

The following examples show how to use com.facebook.presto.spi.TableNotFoundException. 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: ElasticsearchMetadata.java    From presto-connectors with Apache License 2.0 6 votes vote down vote up
@Override
    public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle)
    {
        ElasticsearchTableHandle handle = (ElasticsearchTableHandle) tableHandle;
        checkArgument(handle.getConnectorId().equals(connectorId), "tableHandle is not for this connector");

        ElasticsearchTable table = client.getTable(handle.getSchemaTableName());
        if (table == null) {
            throw new TableNotFoundException(handle.getSchemaTableName());
        }
        return table.getColumns().stream().collect(Collectors.toMap(x -> x.getName(), x -> x));
//        ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder();
//        for (ElasticsearchColumnHandle column : table.getColumns()) {
//            columnHandles.put(column.getName(), column);
//        }
//        return columnHandles.build();
    }
 
Example #2
Source File: HbaseMetadata.java    From presto-connectors with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle)
{
    HbaseTableHandle handle = (HbaseTableHandle) tableHandle;
    checkArgument(handle.getConnectorId().equals(connectorId), "tableHandle is not for this connector");

    HbaseTable table = client.getTable(handle.toSchemaTableName());
    if (table == null) {
        throw new TableNotFoundException(handle.toSchemaTableName());
    }

    ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder();
    for (HbaseColumnHandle column : table.getColumns()) {
        columnHandles.put(column.getName(), column);
    }
    return columnHandles.build();
}
 
Example #3
Source File: Elasticsearch2Client.java    From presto-connectors with Apache License 2.0 5 votes vote down vote up
public static Collection<Range> getRangesFromDomain(Domain domain)
        throws TableNotFoundException
{
    Collection<Range> rangeBuilder = domain.getValues().getRanges().getOrderedRanges();

    return rangeBuilder;
}
 
Example #4
Source File: Elasticsearch6Client.java    From presto-connectors with Apache License 2.0 5 votes vote down vote up
public static Collection<Range> getRangesFromDomain(Domain domain)
        throws TableNotFoundException
{
    Collection<Range> rangeBuilder = domain.getValues().getRanges().getOrderedRanges();

    return rangeBuilder;
}
 
Example #5
Source File: ElasticsearchMetadata.java    From presto-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle table)
{
    ElasticsearchTableHandle handle = (ElasticsearchTableHandle) table;
    checkArgument(handle.getConnectorId().equals(connectorId), "table is not for this connector");
    SchemaTableName tableName = new SchemaTableName(handle.getSchemaName(), handle.getTableName());
    ConnectorTableMetadata metadata = getTableMetadata(tableName);
    if (metadata == null) {
        throw new TableNotFoundException(tableName);
    }
    return metadata;
}
 
Example #6
Source File: HbaseClient.java    From presto-connectors with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a collection of Hbase Range objects from the given Presto domain.
 * This maps the column constraints of the given Domain to an Hbase Range scan.
 *
 * @param domain Domain, can be null (returns (-inf, +inf) Range)
 * @return A collection of Hbase Range objects
 * @throws TableNotFoundException If the Hbase table is not found
 */
public static Collection<Range> getRangesFromDomain(Optional<Domain> domain)
        throws TableNotFoundException
{
    // if we have no predicate pushdown, use the full range
    if (!domain.isPresent()) {
        return ImmutableSet.of();
    }

    Collection<Range> rangeBuilder = domain.get().getValues().getRanges().getOrderedRanges();

    return rangeBuilder;
}
 
Example #7
Source File: HbaseMetadata.java    From presto-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle table)
{
    HbaseTableHandle handle = (HbaseTableHandle) table;
    checkArgument(handle.getConnectorId().equals(connectorId), "table is not for this connector");
    SchemaTableName tableName = new SchemaTableName(handle.getSchema(), handle.getTable());
    ConnectorTableMetadata metadata = getTableMetadata(tableName);
    if (metadata == null) {
        throw new TableNotFoundException(tableName);
    }
    return metadata;
}
 
Example #8
Source File: Elasticsearch5Client.java    From presto-connectors with Apache License 2.0 5 votes vote down vote up
public static Collection<Range> getRangesFromDomain(Domain domain)
        throws TableNotFoundException
{
    Collection<Range> rangeBuilder = domain.getValues().getRanges().getOrderedRanges();

    return rangeBuilder;
}
 
Example #9
Source File: NativeKuduClientSession.java    From presto-kudu with Apache License 2.0 5 votes vote down vote up
@Override
public KuduTable openTable(SchemaTableName schemaTableName) {
    String rawName = toRawName(schemaTableName);
    try {
        KuduTable table = client.openTable(rawName);
        return table;
    } catch (Exception e) {
        log.debug("Error on doOpenTable: " + e, e);
        if (!listSchemaNames().contains(schemaTableName.getSchemaName())) {
            throw new SchemaNotFoundException(schemaTableName.getSchemaName());
        } else {
            throw new TableNotFoundException(schemaTableName);
        }
    }
}
 
Example #10
Source File: KinesisMetadata.java    From presto-kinesis with Apache License 2.0 5 votes vote down vote up
@Override
public KinesisTableHandle getTableHandle(ConnectorSession session, SchemaTableName schemaTableName)
{
    KinesisStreamDescription table = getDefinedTables().get(schemaTableName);
    if (table == null) {
        throw new TableNotFoundException(schemaTableName);
    }

    return new KinesisTableHandle(connectorId,
            schemaTableName.getSchemaName(),
            schemaTableName.getTableName(),
            table.getStreamName(),
            getDataFormat(table.getMessage()));
}
 
Example #11
Source File: KinesisMetadata.java    From presto-kinesis with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, ColumnHandle> getColumnHandles(ConnectorSession connectorSession, ConnectorTableHandle tableHandle)
{
    KinesisTableHandle kinesisTableHandle = handleResolver.convertTableHandle(tableHandle);

    KinesisStreamDescription kinesisStreamDescription = getDefinedTables().get(kinesisTableHandle.toSchemaTableName());
    if (kinesisStreamDescription == null) {
        throw new TableNotFoundException(kinesisTableHandle.toSchemaTableName());
    }

    ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder();

    int index = 0;
    // Note: partition key and related fields are handled by internalFieldDescriptions below
    KinesisStreamFieldGroup message = kinesisStreamDescription.getMessage();
    if (message != null) {
        List<KinesisStreamFieldDescription> fields = message.getFields();
        if (fields != null) {
            for (KinesisStreamFieldDescription kinesisStreamFieldDescription : fields) {
                columnHandles.put(kinesisStreamFieldDescription.getName(), kinesisStreamFieldDescription.getColumnHandle(connectorId, index++));
            }
        }
    }

    for (KinesisInternalFieldDescription kinesisInternalFieldDescription : internalFieldDescriptions) {
        columnHandles.put(kinesisInternalFieldDescription.getName(), kinesisInternalFieldDescription.getColumnHandle(connectorId, index++, kinesisConnectorConfig.isHideInternalColumns()));
    }

    return columnHandles.build();
}