Search in sources :

Example 1 with JdbcTable

use of io.trino.connector.system.jdbc.JdbcTable in project trino by trinodb.

the class SystemTablesMetadata method applyFilter.

@Override
public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle handle, Constraint constraint) {
    SystemTableHandle table = (SystemTableHandle) handle;
    TupleDomain<ColumnHandle> oldDomain = table.getConstraint();
    TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary());
    if (oldDomain.equals(newDomain) && constraint.predicate().isEmpty()) {
        return Optional.empty();
    }
    SystemTable systemTable = checkAndGetTable(session, table);
    if (systemTable instanceof JdbcTable) {
        TupleDomain<ColumnHandle> filtered = ((JdbcTable) systemTable).applyFilter(session, effectiveConstraint(oldDomain, constraint, newDomain));
        newDomain = newDomain.intersect(filtered);
    }
    if (oldDomain.equals(newDomain)) {
        return Optional.empty();
    }
    if (newDomain.isNone()) {
    // TODO (https://github.com/trinodb/trino/issues/3647) indicate the table scan is empty
    }
    table = new SystemTableHandle(table.getSchemaName(), table.getTableName(), newDomain);
    return Optional.of(new ConstraintApplicationResult<>(table, constraint.getSummary(), false));
}
Also used : ColumnHandle(io.trino.spi.connector.ColumnHandle) SystemTable(io.trino.spi.connector.SystemTable) JdbcTable(io.trino.connector.system.jdbc.JdbcTable)

Aggregations

JdbcTable (io.trino.connector.system.jdbc.JdbcTable)1 ColumnHandle (io.trino.spi.connector.ColumnHandle)1 SystemTable (io.trino.spi.connector.SystemTable)1