Search in sources :

Example 6 with DynamicFiltersStats

use of io.trino.server.DynamicFilterService.DynamicFiltersStats in project trino by trinodb.

the class BaseDynamicPartitionPruningTest method testRightJoinWithEmptyBuildSide.

@Test(timeOut = 30_000)
public void testRightJoinWithEmptyBuildSide() {
    @Language("SQL") String selectQuery = "SELECT * FROM partitioned_lineitem l RIGHT JOIN supplier s ON l.suppkey = s.suppkey WHERE name = 'abc'";
    ResultWithQueryId<MaterializedResult> result = getDistributedQueryRunner().executeWithQueryId(getSession(), selectQuery);
    MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
    assertEqualsIgnoreOrder(result.getResult(), expected);
    OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), getQualifiedTableName(PARTITIONED_LINEITEM));
    assertEquals(probeStats.getInputPositions(), 0L);
    DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
    assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
    assertEquals(dynamicFiltersStats.getLazyDynamicFilters(), 1L);
    assertEquals(dynamicFiltersStats.getReplicatedDynamicFilters(), 0L);
    assertEquals(dynamicFiltersStats.getDynamicFiltersCompleted(), 1L);
    DynamicFilterDomainStats domainStats = getOnlyElement(dynamicFiltersStats.getDynamicFilterDomainStats());
    assertEquals(domainStats.getSimplifiedDomain(), none(BIGINT).toString(getSession().toConnectorSession()));
}
Also used : DynamicFilterDomainStats(io.trino.server.DynamicFilterService.DynamicFilterDomainStats) Language(org.intellij.lang.annotations.Language) DynamicFiltersTestUtil.getSimplifiedDomainString(io.trino.util.DynamicFiltersTestUtil.getSimplifiedDomainString) OperatorStats(io.trino.operator.OperatorStats) DynamicFiltersStats(io.trino.server.DynamicFilterService.DynamicFiltersStats) Test(org.testng.annotations.Test)

Example 7 with DynamicFiltersStats

use of io.trino.server.DynamicFilterService.DynamicFiltersStats in project trino by trinodb.

the class BaseDynamicPartitionPruningTest method testJoinWithMultipleDynamicFiltersOnProbe.

@Test(timeOut = 30_000)
public void testJoinWithMultipleDynamicFiltersOnProbe() {
    // supplier names Supplier#000000001 and Supplier#000000002 match suppkey 1 and 2
    @Language("SQL") String selectQuery = "SELECT * FROM (" + "SELECT supplier.suppkey FROM " + "partitioned_lineitem JOIN tpch.tiny.supplier ON partitioned_lineitem.suppkey = supplier.suppkey AND supplier.name IN ('Supplier#000000001', 'Supplier#000000002')" + ") t JOIN supplier ON t.suppkey = supplier.suppkey AND supplier.suppkey IN (2, 3)";
    ResultWithQueryId<MaterializedResult> result = getDistributedQueryRunner().executeWithQueryId(getSession(), selectQuery);
    MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
    assertEqualsIgnoreOrder(result.getResult(), expected);
    OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), getQualifiedTableName(PARTITIONED_LINEITEM));
    // Probe-side is partially scanned
    assertEquals(probeStats.getInputPositions(), 558L);
    DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
    assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 2L);
    assertEquals(dynamicFiltersStats.getLazyDynamicFilters(), 2L);
    assertEquals(dynamicFiltersStats.getReplicatedDynamicFilters(), 0L);
    assertEquals(dynamicFiltersStats.getDynamicFiltersCompleted(), 2);
    List<DynamicFilterDomainStats> domainStats = dynamicFiltersStats.getDynamicFilterDomainStats();
    assertThat(domainStats).map(DynamicFilterDomainStats::getSimplifiedDomain).containsExactlyInAnyOrder(getSimplifiedDomainString(2L, 3L, 2, BIGINT), getSimplifiedDomainString(2L, 2L, 1, BIGINT));
}
Also used : DynamicFilterDomainStats(io.trino.server.DynamicFilterService.DynamicFilterDomainStats) Language(org.intellij.lang.annotations.Language) DynamicFiltersTestUtil.getSimplifiedDomainString(io.trino.util.DynamicFiltersTestUtil.getSimplifiedDomainString) OperatorStats(io.trino.operator.OperatorStats) DynamicFiltersStats(io.trino.server.DynamicFilterService.DynamicFiltersStats) Test(org.testng.annotations.Test)

Example 8 with DynamicFiltersStats

use of io.trino.server.DynamicFilterService.DynamicFiltersStats in project trino by trinodb.

the class BaseDynamicPartitionPruningTest method testJoinWithSelectiveBuildSide.

@Test(timeOut = 30_000)
public void testJoinWithSelectiveBuildSide() {
    @Language("SQL") String selectQuery = "SELECT * FROM partitioned_lineitem JOIN supplier ON partitioned_lineitem.suppkey = supplier.suppkey " + "AND supplier.name = 'Supplier#000000001'";
    ResultWithQueryId<MaterializedResult> result = getDistributedQueryRunner().executeWithQueryId(getSession(), selectQuery);
    MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
    assertEqualsIgnoreOrder(result.getResult(), expected);
    OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), getQualifiedTableName(PARTITIONED_LINEITEM));
    // Probe-side is partially scanned
    assertEquals(probeStats.getInputPositions(), 615L);
    DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
    assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
    assertEquals(dynamicFiltersStats.getLazyDynamicFilters(), 1L);
    assertEquals(dynamicFiltersStats.getReplicatedDynamicFilters(), 0L);
    assertEquals(dynamicFiltersStats.getDynamicFiltersCompleted(), 1L);
    DynamicFilterDomainStats domainStats = getOnlyElement(dynamicFiltersStats.getDynamicFilterDomainStats());
    assertEquals(domainStats.getSimplifiedDomain(), singleValue(BIGINT, 1L).toString(getSession().toConnectorSession()));
}
Also used : DynamicFilterDomainStats(io.trino.server.DynamicFilterService.DynamicFilterDomainStats) Language(org.intellij.lang.annotations.Language) DynamicFiltersTestUtil.getSimplifiedDomainString(io.trino.util.DynamicFiltersTestUtil.getSimplifiedDomainString) OperatorStats(io.trino.operator.OperatorStats) DynamicFiltersStats(io.trino.server.DynamicFilterService.DynamicFiltersStats) Test(org.testng.annotations.Test)

Example 9 with DynamicFiltersStats

use of io.trino.server.DynamicFilterService.DynamicFiltersStats in project trino by trinodb.

the class BaseDynamicPartitionPruningTest method testSemiJoinWithEmptyBuildSide.

@Test(timeOut = 30_000)
public void testSemiJoinWithEmptyBuildSide() {
    @Language("SQL") String selectQuery = "SELECT * FROM partitioned_lineitem WHERE suppkey IN (SELECT suppkey FROM supplier WHERE name = 'abc')";
    ResultWithQueryId<MaterializedResult> result = getDistributedQueryRunner().executeWithQueryId(getSession(), selectQuery);
    MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
    assertEqualsIgnoreOrder(result.getResult(), expected);
    OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), getQualifiedTableName(PARTITIONED_LINEITEM));
    assertEquals(probeStats.getInputPositions(), 0L);
    DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
    assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
    assertEquals(dynamicFiltersStats.getLazyDynamicFilters(), 1L);
    assertEquals(dynamicFiltersStats.getReplicatedDynamicFilters(), 0L);
    assertEquals(dynamicFiltersStats.getDynamicFiltersCompleted(), 1L);
    DynamicFilterDomainStats domainStats = getOnlyElement(dynamicFiltersStats.getDynamicFilterDomainStats());
    assertEquals(domainStats.getSimplifiedDomain(), none(BIGINT).toString(getSession().toConnectorSession()));
}
Also used : DynamicFilterDomainStats(io.trino.server.DynamicFilterService.DynamicFilterDomainStats) Language(org.intellij.lang.annotations.Language) DynamicFiltersTestUtil.getSimplifiedDomainString(io.trino.util.DynamicFiltersTestUtil.getSimplifiedDomainString) OperatorStats(io.trino.operator.OperatorStats) DynamicFiltersStats(io.trino.server.DynamicFilterService.DynamicFiltersStats) Test(org.testng.annotations.Test)

Example 10 with DynamicFiltersStats

use of io.trino.server.DynamicFilterService.DynamicFiltersStats in project trino by trinodb.

the class BaseDynamicPartitionPruningTest method testRightJoinWithNonSelectiveBuildSide.

@Test(timeOut = 30_000)
public void testRightJoinWithNonSelectiveBuildSide() {
    @Language("SQL") String selectQuery = "SELECT * FROM partitioned_lineitem l RIGHT JOIN supplier s ON l.suppkey = s.suppkey";
    ResultWithQueryId<MaterializedResult> result = getDistributedQueryRunner().executeWithQueryId(getSession(), selectQuery);
    MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
    assertEqualsIgnoreOrder(result.getResult(), expected);
    OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), getQualifiedTableName(PARTITIONED_LINEITEM));
    // Probe-side is fully scanned
    assertEquals(probeStats.getInputPositions(), LINEITEM_COUNT);
    DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
    assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
    assertEquals(dynamicFiltersStats.getLazyDynamicFilters(), 1L);
    assertEquals(dynamicFiltersStats.getReplicatedDynamicFilters(), 0L);
    assertEquals(dynamicFiltersStats.getDynamicFiltersCompleted(), 1L);
    DynamicFilterDomainStats domainStats = getOnlyElement(dynamicFiltersStats.getDynamicFilterDomainStats());
    assertThat(domainStats.getSimplifiedDomain()).isEqualTo(getSimplifiedDomainString(1L, 100L, 100, BIGINT));
}
Also used : DynamicFilterDomainStats(io.trino.server.DynamicFilterService.DynamicFilterDomainStats) Language(org.intellij.lang.annotations.Language) DynamicFiltersTestUtil.getSimplifiedDomainString(io.trino.util.DynamicFiltersTestUtil.getSimplifiedDomainString) OperatorStats(io.trino.operator.OperatorStats) DynamicFiltersStats(io.trino.server.DynamicFilterService.DynamicFiltersStats) Test(org.testng.annotations.Test)

Aggregations

DynamicFilterDomainStats (io.trino.server.DynamicFilterService.DynamicFilterDomainStats)18 DynamicFiltersStats (io.trino.server.DynamicFilterService.DynamicFiltersStats)18 Test (org.testng.annotations.Test)18 OperatorStats (io.trino.operator.OperatorStats)14 Language (org.intellij.lang.annotations.Language)14 DynamicFiltersTestUtil.getSimplifiedDomainString (io.trino.util.DynamicFiltersTestUtil.getSimplifiedDomainString)13 StageId (io.trino.execution.StageId)4 TaskId (io.trino.execution.TaskId)4 QueryId (io.trino.spi.QueryId)4 DynamicFilterId (io.trino.sql.planner.plan.DynamicFilterId)4 DynamicFilter (io.trino.spi.connector.DynamicFilter)2 TestingColumnHandle (io.trino.spi.connector.TestingColumnHandle)2 DynamicFilters.createDynamicFilterExpression (io.trino.sql.DynamicFilters.createDynamicFilterExpression)2 Symbol (io.trino.sql.planner.Symbol)2 SymbolAllocator (io.trino.sql.planner.SymbolAllocator)2 Expression (io.trino.sql.tree.Expression)2 Domain (io.trino.spi.predicate.Domain)1 TupleDomain (io.trino.spi.predicate.TupleDomain)1