Search in sources :

Example 1 with DynamicFilterPlaceholder

use of com.facebook.presto.expressions.DynamicFilters.DynamicFilterPlaceholder in project presto by prestodb.

the class TestLocalDynamicFilter method testMultiplePartitionsAndColumns.

@Test
public void testMultiplePartitionsAndColumns() throws ExecutionException, InterruptedException {
    LocalDynamicFilter filter = new LocalDynamicFilter(ImmutableMultimap.of("123", new DynamicFilterPlaceholder("123", new VariableReferenceExpression(Optional.empty(), "a", INTEGER), EQUAL), "456", new DynamicFilterPlaceholder("456", new VariableReferenceExpression(Optional.empty(), "b", BIGINT), EQUAL)), ImmutableMap.of("123", 0, "456", 1), 2);
    assertEquals(filter.getBuildChannels(), ImmutableMap.of("123", 0, "456", 1));
    Consumer<TupleDomain<String>> consumer = filter.getTupleDomainConsumer();
    ListenableFuture<TupleDomain<VariableReferenceExpression>> result = filter.getResultFuture();
    assertFalse(result.isDone());
    consumer.accept(TupleDomain.withColumnDomains(ImmutableMap.of("123", Domain.singleValue(INTEGER, 10L), "456", Domain.singleValue(BIGINT, 100L))));
    assertFalse(result.isDone());
    consumer.accept(TupleDomain.withColumnDomains(ImmutableMap.of("123", Domain.singleValue(INTEGER, 20L), "456", Domain.singleValue(BIGINT, 200L))));
    assertEquals(result.get(), TupleDomain.withColumnDomains(ImmutableMap.of(new VariableReferenceExpression(Optional.empty(), "a", INTEGER), Domain.multipleValues(INTEGER, ImmutableList.of(10L, 20L)), new VariableReferenceExpression(Optional.empty(), "b", BIGINT), Domain.multipleValues(BIGINT, ImmutableList.of(100L, 200L)))));
}
Also used : TupleDomain(com.facebook.presto.common.predicate.TupleDomain) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) DynamicFilterPlaceholder(com.facebook.presto.expressions.DynamicFilters.DynamicFilterPlaceholder) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Example 2 with DynamicFilterPlaceholder

use of com.facebook.presto.expressions.DynamicFilters.DynamicFilterPlaceholder in project presto by prestodb.

the class TestLocalDynamicFilter method testMultipleColumns.

@Test
public void testMultipleColumns() throws ExecutionException, InterruptedException {
    LocalDynamicFilter filter = new LocalDynamicFilter(ImmutableMultimap.of("123", new DynamicFilterPlaceholder("123", new VariableReferenceExpression(Optional.empty(), "a", INTEGER), EQUAL), "456", new DynamicFilterPlaceholder("456", new VariableReferenceExpression(Optional.empty(), "b", INTEGER), EQUAL)), ImmutableMap.of("123", 0, "456", 1), 1);
    assertEquals(filter.getBuildChannels(), ImmutableMap.of("123", 0, "456", 1));
    Consumer<TupleDomain<String>> consumer = filter.getTupleDomainConsumer();
    ListenableFuture<TupleDomain<VariableReferenceExpression>> result = filter.getResultFuture();
    assertFalse(result.isDone());
    consumer.accept(TupleDomain.withColumnDomains(ImmutableMap.of("123", Domain.singleValue(INTEGER, 10L), "456", Domain.singleValue(INTEGER, 20L))));
    assertEquals(result.get(), TupleDomain.withColumnDomains(ImmutableMap.of(new VariableReferenceExpression(Optional.empty(), "a", INTEGER), Domain.singleValue(INTEGER, 10L), new VariableReferenceExpression(Optional.empty(), "b", INTEGER), Domain.singleValue(INTEGER, 20L))));
}
Also used : TupleDomain(com.facebook.presto.common.predicate.TupleDomain) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) DynamicFilterPlaceholder(com.facebook.presto.expressions.DynamicFilters.DynamicFilterPlaceholder) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Example 3 with DynamicFilterPlaceholder

use of com.facebook.presto.expressions.DynamicFilters.DynamicFilterPlaceholder in project presto by prestodb.

the class TestLocalDynamicFilter method testMultiplePartitions.

@Test
public void testMultiplePartitions() throws ExecutionException, InterruptedException {
    LocalDynamicFilter filter = new LocalDynamicFilter(ImmutableMultimap.of("123", new DynamicFilterPlaceholder("123", new VariableReferenceExpression(Optional.empty(), "a", INTEGER), EQUAL)), ImmutableMap.of("123", 0), 2);
    assertEquals(filter.getBuildChannels(), ImmutableMap.of("123", 0));
    Consumer<TupleDomain<String>> consumer = filter.getTupleDomainConsumer();
    ListenableFuture<TupleDomain<VariableReferenceExpression>> result = filter.getResultFuture();
    assertFalse(result.isDone());
    consumer.accept(TupleDomain.withColumnDomains(ImmutableMap.of("123", Domain.singleValue(INTEGER, 10L))));
    assertFalse(result.isDone());
    consumer.accept(TupleDomain.withColumnDomains(ImmutableMap.of("123", Domain.singleValue(INTEGER, 20L))));
    assertEquals(result.get(), TupleDomain.withColumnDomains(ImmutableMap.of(new VariableReferenceExpression(Optional.empty(), "a", INTEGER), Domain.multipleValues(INTEGER, ImmutableList.of(10L, 20L)))));
}
Also used : TupleDomain(com.facebook.presto.common.predicate.TupleDomain) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) DynamicFilterPlaceholder(com.facebook.presto.expressions.DynamicFilters.DynamicFilterPlaceholder) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Example 4 with DynamicFilterPlaceholder

use of com.facebook.presto.expressions.DynamicFilters.DynamicFilterPlaceholder in project presto by prestodb.

the class TestLocalDynamicFilter method testMultipleProbeVariables.

@Test
public void testMultipleProbeVariables() throws ExecutionException, InterruptedException {
    LocalDynamicFilter filter = new LocalDynamicFilter(ImmutableMultimap.of("123", new DynamicFilterPlaceholder("123", new VariableReferenceExpression(Optional.empty(), "a1", INTEGER), EQUAL), "123", new DynamicFilterPlaceholder("123", new VariableReferenceExpression(Optional.empty(), "a2", INTEGER), EQUAL)), ImmutableMap.of("123", 0), 1);
    assertEquals(filter.getBuildChannels(), ImmutableMap.of("123", 0));
    Consumer<TupleDomain<String>> consumer = filter.getTupleDomainConsumer();
    ListenableFuture<TupleDomain<VariableReferenceExpression>> result = filter.getResultFuture();
    assertFalse(result.isDone());
    consumer.accept(TupleDomain.withColumnDomains(ImmutableMap.of("123", Domain.singleValue(INTEGER, 7L))));
    assertEquals(result.get(), TupleDomain.withColumnDomains(ImmutableMap.of(new VariableReferenceExpression(Optional.empty(), "a1", INTEGER), Domain.singleValue(INTEGER, 7L), new VariableReferenceExpression(Optional.empty(), "a2", INTEGER), Domain.singleValue(INTEGER, 7L))));
}
Also used : TupleDomain(com.facebook.presto.common.predicate.TupleDomain) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) DynamicFilterPlaceholder(com.facebook.presto.expressions.DynamicFilters.DynamicFilterPlaceholder) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Example 5 with DynamicFilterPlaceholder

use of com.facebook.presto.expressions.DynamicFilters.DynamicFilterPlaceholder in project presto by prestodb.

the class TestLocalDynamicFilter method testNone.

@Test
public void testNone() throws ExecutionException, InterruptedException {
    LocalDynamicFilter filter = new LocalDynamicFilter(ImmutableMultimap.of("123", new DynamicFilterPlaceholder("123", new VariableReferenceExpression(Optional.empty(), "a", INTEGER), EQUAL)), ImmutableMap.of("123", 0), 1);
    assertEquals(filter.getBuildChannels(), ImmutableMap.of("123", 0));
    Consumer<TupleDomain<String>> consumer = filter.getTupleDomainConsumer();
    ListenableFuture<TupleDomain<VariableReferenceExpression>> result = filter.getResultFuture();
    assertFalse(result.isDone());
    consumer.accept(TupleDomain.withColumnDomains(ImmutableMap.of("123", Domain.none(INTEGER))));
    assertEquals(result.get(), TupleDomain.withColumnDomains(ImmutableMap.of(new VariableReferenceExpression(Optional.empty(), "a", INTEGER), Domain.none(INTEGER))));
}
Also used : TupleDomain(com.facebook.presto.common.predicate.TupleDomain) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) DynamicFilterPlaceholder(com.facebook.presto.expressions.DynamicFilters.DynamicFilterPlaceholder) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Aggregations

TupleDomain (com.facebook.presto.common.predicate.TupleDomain)8 DynamicFilterPlaceholder (com.facebook.presto.expressions.DynamicFilters.DynamicFilterPlaceholder)8 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)8 BasePlanTest (com.facebook.presto.sql.planner.assertions.BasePlanTest)6 Test (org.testng.annotations.Test)6 Domain (com.facebook.presto.common.predicate.Domain)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Map (java.util.Map)2 Collectors.toMap (java.util.stream.Collectors.toMap)2 DynamicFilterExtractResult (com.facebook.presto.expressions.DynamicFilters.DynamicFilterExtractResult)1 DynamicFilters.extractDynamicFilters (com.facebook.presto.expressions.DynamicFilters.extractDynamicFilters)1 FilterNode (com.facebook.presto.spi.plan.FilterNode)1 PlanNode (com.facebook.presto.spi.plan.PlanNode)1 TableScanNode (com.facebook.presto.spi.plan.TableScanNode)1 PlanNodeSearcher (com.facebook.presto.sql.planner.optimizations.PlanNodeSearcher)1 AbstractJoinNode (com.facebook.presto.sql.planner.plan.AbstractJoinNode)1 MoreObjects.toStringHelper (com.google.common.base.MoreObjects.toStringHelper)1 Verify.verify (com.google.common.base.Verify.verify)1 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)1 Multimap (com.google.common.collect.Multimap)1