Search in sources :

Example 6 with OperatorStats

use of io.trino.operator.OperatorStats in project trino by trinodb.

the class BaseIcebergConnectorTest method verifySplitCount.

private void verifySplitCount(QueryId queryId, long expectedSplitCount) {
    checkArgument(expectedSplitCount >= 0);
    OperatorStats operatorStats = getOperatorStats(queryId);
    if (expectedSplitCount > 0) {
        assertThat(operatorStats.getTotalDrivers()).isEqualTo(expectedSplitCount);
        assertThat(operatorStats.getPhysicalInputPositions()).isGreaterThan(0);
    } else {
        // expectedSplitCount == 0
        assertThat(operatorStats.getTotalDrivers()).isEqualTo(1);
        assertThat(operatorStats.getPhysicalInputPositions()).isEqualTo(0);
    }
}
Also used : OperatorStats(io.trino.operator.OperatorStats)

Example 7 with OperatorStats

use of io.trino.operator.OperatorStats in project trino by trinodb.

the class BaseIcebergConnectorTest method testLocalDynamicFilteringWithSelectiveBuildSizeJoin.

@Test
public void testLocalDynamicFilteringWithSelectiveBuildSizeJoin() {
    long fullTableScan = (Long) computeActual("SELECT count(*) FROM lineitem").getOnlyValue();
    // Pick a value for totalprice where file level stats will not be able to filter out any data
    // This assumes the totalprice ranges in every file have some overlap, otherwise this test will fail.
    MaterializedRow range = getOnlyElement(computeActual("SELECT max(lower_bounds[4]), min(upper_bounds[4]) FROM \"orders$files\"").getMaterializedRows());
    double totalPrice = (Double) computeActual(format("SELECT totalprice FROM orders WHERE totalprice > %s AND totalprice < %s LIMIT 1", range.getField(0), range.getField(1))).getOnlyValue();
    Session session = Session.builder(getSession()).setSystemProperty(JOIN_DISTRIBUTION_TYPE, BROADCAST.name()).build();
    ResultWithQueryId<MaterializedResult> result = getDistributedQueryRunner().executeWithQueryId(session, "SELECT * FROM lineitem JOIN orders ON lineitem.orderkey = orders.orderkey AND orders.totalprice = " + totalPrice);
    OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), new QualifiedObjectName(ICEBERG_CATALOG, "tpch", "lineitem"));
    // Assert some lineitem rows were filtered out on file level
    assertThat(probeStats.getInputPositions()).isLessThan(fullTableScan);
}
Also used : OperatorStats(io.trino.operator.OperatorStats) MaterializedResult(io.trino.testing.MaterializedResult) MaterializedRow(io.trino.testing.MaterializedRow) QualifiedObjectName(io.trino.metadata.QualifiedObjectName) Session(io.trino.Session) Test(org.testng.annotations.Test) BaseConnectorTest(io.trino.testing.BaseConnectorTest)

Example 8 with OperatorStats

use of io.trino.operator.OperatorStats in project trino by trinodb.

the class BaseDynamicPartitionPruningTest method testJoinWithImplicitCoercion.

@Test(timeOut = 30_000)
public void testJoinWithImplicitCoercion() {
    // setup partitioned fact table with integer suppkey
    createLineitemTable("partitioned_lineitem_int", ImmutableList.of("orderkey", "CAST(suppkey as int) suppkey_int"), ImmutableList.of("suppkey_int"));
    assertQuery("SELECT count(*) FROM partitioned_lineitem_int", "VALUES " + LINEITEM_COUNT);
    @Language("SQL") String selectQuery = "SELECT * FROM partitioned_lineitem_int l JOIN supplier s ON l.suppkey_int = s.suppkey AND s.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_int"));
    // 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 OperatorStats

use of io.trino.operator.OperatorStats in project trino by trinodb.

the class BaseDynamicPartitionPruningTest method testSemiJoinLargeBuildSideRangeDynamicFiltering.

@Test(timeOut = 30_000)
public void testSemiJoinLargeBuildSideRangeDynamicFiltering() {
    @Language("SQL") String selectQuery = "SELECT * FROM partitioned_lineitem WHERE orderkey IN (SELECT orderkey FROM orders)";
    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 because the build-side is too large for dynamic filtering
    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());
    assertEquals(domainStats.getSimplifiedDomain(), Domain.create(ValueSet.ofRanges(range(BIGINT, 1L, true, 60000L, true)), false).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 OperatorStats

use of io.trino.operator.OperatorStats in project trino by trinodb.

the class BaseDynamicPartitionPruningTest method testJoinLargeBuildSideRangeDynamicFiltering.

@Test(timeOut = 30_000)
public void testJoinLargeBuildSideRangeDynamicFiltering() {
    @Language("SQL") String selectQuery = "SELECT * FROM partitioned_lineitem JOIN orders ON partitioned_lineitem.orderkey = orders.orderkey";
    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 because the build-side is too large for dynamic filtering
    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());
    assertEquals(domainStats.getSimplifiedDomain(), Domain.create(ValueSet.ofRanges(range(BIGINT, 1L, true, 60000L, true)), false).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)

Aggregations

OperatorStats (io.trino.operator.OperatorStats)29 Test (org.testng.annotations.Test)18 Language (org.intellij.lang.annotations.Language)15 DynamicFilterDomainStats (io.trino.server.DynamicFilterService.DynamicFilterDomainStats)14 DynamicFiltersStats (io.trino.server.DynamicFilterService.DynamicFiltersStats)14 DynamicFiltersTestUtil.getSimplifiedDomainString (io.trino.util.DynamicFiltersTestUtil.getSimplifiedDomainString)13 ImmutableList (com.google.common.collect.ImmutableList)4 Session (io.trino.Session)3 MaterializedResult (io.trino.testing.MaterializedResult)3 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 Duration (io.airlift.units.Duration)2 QueryStats (io.trino.execution.QueryStats)2 QualifiedObjectName (io.trino.metadata.QualifiedObjectName)2 BlockedReason (io.trino.operator.BlockedReason)2 PipelineStats (io.trino.operator.PipelineStats)2 StageGcStatistics (io.trino.spi.eventlistener.StageGcStatistics)2 PlanFragment (io.trino.sql.planner.PlanFragment)2 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)2 BaseConnectorTest (io.trino.testing.BaseConnectorTest)2 HashSet (java.util.HashSet)2