use of com.facebook.presto.common.Subfield in project presto by prestodb.
the class ListSelectiveStreamReader method getTopLevelFilter.
private static Optional<TupleDomainFilter> getTopLevelFilter(Map<Subfield, TupleDomainFilter> filters) {
Map<Subfield, TupleDomainFilter> topLevelFilters = Maps.filterEntries(filters, entry -> entry.getKey().getPath().isEmpty());
if (topLevelFilters.isEmpty()) {
return Optional.empty();
}
checkArgument(topLevelFilters.size() == 1, "ARRAY column may have at most one top-level range filter");
TupleDomainFilter filter = Iterables.getOnlyElement(topLevelFilters.values());
checkArgument(filter == IS_NULL || filter == IS_NOT_NULL, "Top-level range filter on ARRAY column must be IS NULL or IS NOT NULL");
return Optional.of(filter);
}
use of com.facebook.presto.common.Subfield in project presto by prestodb.
the class MapDirectSelectiveStreamReader method getTopLevelFilter.
private static Optional<TupleDomainFilter> getTopLevelFilter(Map<Subfield, TupleDomainFilter> filters) {
Map<Subfield, TupleDomainFilter> topLevelFilters = Maps.filterEntries(filters, entry -> entry.getKey().getPath().isEmpty());
if (topLevelFilters.isEmpty()) {
return Optional.empty();
}
checkArgument(topLevelFilters.size() == 1, "MAP column may have at most one top-level range filter");
TupleDomainFilter filter = Iterables.getOnlyElement(topLevelFilters.values());
checkArgument(filter == IS_NULL || filter == IS_NOT_NULL, "Top-level range filter on MAP column must be IS NULL or IS NOT NULL");
return Optional.of(filter);
}
use of com.facebook.presto.common.Subfield in project presto by prestodb.
the class MapFlatSelectiveStreamReader method getTopLevelFilter.
private static Optional<TupleDomainFilter> getTopLevelFilter(Map<Subfield, TupleDomainFilter> filters) {
Map<Subfield, TupleDomainFilter> topLevelFilters = Maps.filterEntries(filters, entry -> entry.getKey().getPath().isEmpty());
if (topLevelFilters.isEmpty()) {
return Optional.empty();
}
checkArgument(topLevelFilters.size() == 1, "MAP column may have at most one top-level range filter");
TupleDomainFilter filter = Iterables.getOnlyElement(topLevelFilters.values());
checkArgument(filter == IS_NULL || filter == IS_NOT_NULL, "Top-level range filter on MAP column must be IS NULL or IS NOT NULL");
return Optional.of(filter);
}
use of com.facebook.presto.common.Subfield in project presto by prestodb.
the class TestHiveLogicalPlanner method testPushdownFilterOnSubfields.
@Test
public void testPushdownFilterOnSubfields() {
assertUpdate("CREATE TABLE test_pushdown_filter_on_subfields(" + "id bigint, " + "a array(bigint), " + "b map(varchar, bigint), " + "c row(" + "a bigint, " + "b row(x bigint), " + "c array(bigint), " + "d map(bigint, bigint), " + "e map(varchar, bigint)))");
assertPushdownFilterOnSubfields("SELECT * FROM test_pushdown_filter_on_subfields WHERE a[1] = 1", ImmutableMap.of(new Subfield("a[1]"), singleValue(BIGINT, 1L)));
assertPushdownFilterOnSubfields("SELECT * FROM test_pushdown_filter_on_subfields where a[1 + 1] = 1", ImmutableMap.of(new Subfield("a[2]"), singleValue(BIGINT, 1L)));
assertPushdownFilterOnSubfields("SELECT * FROM test_pushdown_filter_on_subfields WHERE b['foo'] = 1", ImmutableMap.of(new Subfield("b[\"foo\"]"), singleValue(BIGINT, 1L)));
assertPushdownFilterOnSubfields("SELECT * FROM test_pushdown_filter_on_subfields WHERE b[concat('f','o', 'o')] = 1", ImmutableMap.of(new Subfield("b[\"foo\"]"), singleValue(BIGINT, 1L)));
assertPushdownFilterOnSubfields("SELECT * FROM test_pushdown_filter_on_subfields WHERE c.a = 1", ImmutableMap.of(new Subfield("c.a"), singleValue(BIGINT, 1L)));
assertPushdownFilterOnSubfields("SELECT * FROM test_pushdown_filter_on_subfields WHERE c.b.x = 1", ImmutableMap.of(new Subfield("c.b.x"), singleValue(BIGINT, 1L)));
assertPushdownFilterOnSubfields("SELECT * FROM test_pushdown_filter_on_subfields WHERE c.c[5] = 1", ImmutableMap.of(new Subfield("c.c[5]"), singleValue(BIGINT, 1L)));
assertPushdownFilterOnSubfields("SELECT * FROM test_pushdown_filter_on_subfields WHERE c.d[5] = 1", ImmutableMap.of(new Subfield("c.d[5]"), singleValue(BIGINT, 1L)));
assertPushdownFilterOnSubfields("SELECT * FROM test_pushdown_filter_on_subfields WHERE c.e[concat('f', 'o', 'o')] = 1", ImmutableMap.of(new Subfield("c.e[\"foo\"]"), singleValue(BIGINT, 1L)));
assertPushdownFilterOnSubfields("SELECT * FROM test_pushdown_filter_on_subfields WHERE c.e['foo'] = 1", ImmutableMap.of(new Subfield("c.e[\"foo\"]"), singleValue(BIGINT, 1L)));
assertPushdownFilterOnSubfields("SELECT * FROM test_pushdown_filter_on_subfields WHERE c.a IS NOT NULL AND c.c IS NOT NULL", ImmutableMap.of(new Subfield("c.a"), notNull(BIGINT), new Subfield("c.c"), notNull(new ArrayType(BIGINT))));
// TupleDomain predicate is always FALSE
assertPlan(pushdownFilterEnabled(), "SELECT id FROM test_pushdown_filter_on_subfields WHERE c.a = 1 AND c.a = 2", output(values("id")));
assertUpdate("DROP TABLE test_pushdown_filter_on_subfields");
}
Aggregations