Skip to content

Commit

Permalink
Restore dynamic partition pruning assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
sopel39 committed Nov 22, 2021
1 parent bbbb42a commit 51023d8
Showing 1 changed file with 48 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import io.trino.Session;
import io.trino.metadata.QualifiedObjectName;
import io.trino.operator.OperatorStats;
import io.trino.server.DynamicFilterService.DynamicFilterDomainStats;
import io.trino.server.DynamicFilterService.DynamicFiltersStats;
import io.trino.spi.QueryId;
Expand Down Expand Up @@ -96,8 +98,8 @@ public void testJoinWithEmptyBuildSide()
MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
assertEqualsIgnoreOrder(result.getResult(), expected);

// TODO bring back OperatorStats assertions from https://github.com/trinodb/trino/commit/1feaa0f928a02f577c8ac9ef6cc0c8ec2008a46d
// after https://github.com/trinodb/trino/issues/5120 is fixed
OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), getQualifiedTableName(PARTITIONED_LINEITEM));
assertEquals(probeStats.getInputPositions(), 0L);

DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
Expand All @@ -121,8 +123,9 @@ public void testJoinWithSelectiveBuildSide()
MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
assertEqualsIgnoreOrder(result.getResult(), expected);

// TODO bring back OperatorStats assertions from https://github.com/trinodb/trino/commit/1feaa0f928a02f577c8ac9ef6cc0c8ec2008a46d
// after https://github.com/trinodb/trino/issues/5120 is fixed
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);
Expand All @@ -144,8 +147,9 @@ public void testJoinWithNonSelectiveBuildSide()
MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
assertEqualsIgnoreOrder(result.getResult(), expected);

// TODO bring back OperatorStats assertions from https://github.com/trinodb/trino/commit/1feaa0f928a02f577c8ac9ef6cc0c8ec2008a46d
// after https://github.com/trinodb/trino/issues/5120 is fixed
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);
Expand All @@ -168,8 +172,9 @@ public void testJoinLargeBuildSideRangeDynamicFiltering()
MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
assertEqualsIgnoreOrder(result.getResult(), expected);

// TODO bring back OperatorStats assertions from https://github.com/trinodb/trino/commit/1feaa0f928a02f577c8ac9ef6cc0c8ec2008a46d
// after https://github.com/trinodb/trino/issues/5120 is fixed
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);
Expand Down Expand Up @@ -198,8 +203,9 @@ public void testJoinWithMultipleDynamicFiltersOnProbe()
MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
assertEqualsIgnoreOrder(result.getResult(), expected);

// TODO bring back OperatorStats assertions from https://github.com/trinodb/trino/commit/1feaa0f928a02f577c8ac9ef6cc0c8ec2008a46d
// after https://github.com/trinodb/trino/issues/5120 is fixed
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);
Expand Down Expand Up @@ -230,6 +236,10 @@ public void testJoinWithImplicitCoercion()
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);
Expand All @@ -249,8 +259,8 @@ public void testSemiJoinWithEmptyBuildSide()
MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
assertEqualsIgnoreOrder(result.getResult(), expected);

// TODO bring back OperatorStats assertions from https://github.com/trinodb/trino/commit/0fb16ab9d9c990e58fad63d4dab3dbbe482a077d
// after https://github.com/trinodb/trino/issues/5120 is fixed
OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), getQualifiedTableName(PARTITIONED_LINEITEM));
assertEquals(probeStats.getInputPositions(), 0L);

DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
Expand All @@ -272,8 +282,9 @@ public void testSemiJoinWithSelectiveBuildSide()
MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
assertEqualsIgnoreOrder(result.getResult(), expected);

// TODO bring back OperatorStats assertions from https://github.com/trinodb/trino/commit/0fb16ab9d9c990e58fad63d4dab3dbbe482a077d
// after https://github.com/trinodb/trino/issues/5120 is fixed
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);
Expand All @@ -295,8 +306,9 @@ public void testSemiJoinWithNonSelectiveBuildSide()
MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
assertEqualsIgnoreOrder(result.getResult(), expected);

// TODO bring back OperatorStats assertions from https://github.com/trinodb/trino/commit/0fb16ab9d9c990e58fad63d4dab3dbbe482a077d
// after https://github.com/trinodb/trino/issues/5120 is fixed
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);
Expand All @@ -319,8 +331,9 @@ public void testSemiJoinLargeBuildSideRangeDynamicFiltering()
MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
assertEqualsIgnoreOrder(result.getResult(), expected);

// TODO bring back OperatorStats assertions from https://github.com/trinodb/trino/commit/0fb16ab9d9c990e58fad63d4dab3dbbe482a077d
// after https://github.com/trinodb/trino/issues/5120 is fixed
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);
Expand All @@ -345,8 +358,8 @@ public void testRightJoinWithEmptyBuildSide()
MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
assertEqualsIgnoreOrder(result.getResult(), expected);

// TODO bring back OperatorStats assertions from https://github.com/trinodb/trino/commit/0fb16ab9d9c990e58fad63d4dab3dbbe482a077d
// after https://github.com/trinodb/trino/issues/5120 is fixed
OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), getQualifiedTableName(PARTITIONED_LINEITEM));
assertEquals(probeStats.getInputPositions(), 0L);

DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
Expand All @@ -368,8 +381,9 @@ public void testRightJoinWithSelectiveBuildSide()
MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
assertEqualsIgnoreOrder(result.getResult(), expected);

// TODO bring back OperatorStats assertions from https://github.com/trinodb/trino/commit/0fb16ab9d9c990e58fad63d4dab3dbbe482a077d
// after https://github.com/trinodb/trino/issues/5120 is fixed
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);
Expand All @@ -391,8 +405,9 @@ public void testRightJoinWithNonSelectiveBuildSide()
MaterializedResult expected = computeActual(withDynamicFilteringDisabled(), selectQuery);
assertEqualsIgnoreOrder(result.getResult(), expected);

// TODO bring back OperatorStats assertions from https://github.com/trinodb/trino/commit/0fb16ab9d9c990e58fad63d4dab3dbbe482a077d
// after https://github.com/trinodb/trino/issues/5120 is fixed
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);
Expand Down Expand Up @@ -420,4 +435,13 @@ private Session withDynamicFilteringDisabled()
.setSystemProperty("enable_dynamic_filtering", "false")
.build();
}

private QualifiedObjectName getQualifiedTableName(String tableName)
{
Session session = getQueryRunner().getDefaultSession();
return new QualifiedObjectName(
session.getCatalog().orElseThrow(),
session.getSchema().orElseThrow(),
tableName);
}
}

0 comments on commit 51023d8

Please sign in to comment.