Skip to content

Commit

Permalink
Remove OperatorStats related flaky assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
raunaqmorarka authored and sopel39 committed Sep 16, 2020
1 parent 39a165f commit 9faddbe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.google.common.collect.ImmutableMap;
import io.airlift.log.Logger;
import io.prestosql.Session;
import io.prestosql.operator.OperatorStats;
import io.prestosql.spi.QueryId;
import io.prestosql.spi.predicate.Domain;
import io.prestosql.spi.predicate.ValueSet;
Expand All @@ -34,7 +33,6 @@
import static com.google.common.collect.Iterables.getOnlyElement;
import static io.airlift.testing.Assertions.assertGreaterThan;
import static io.airlift.testing.Assertions.assertGreaterThanOrEqual;
import static io.airlift.testing.Assertions.assertLessThanOrEqual;
import static io.airlift.units.Duration.nanosSince;
import static io.prestosql.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE;
import static io.prestosql.SystemSessionProperties.JOIN_REORDERING_STRATEGY;
Expand Down Expand Up @@ -99,9 +97,8 @@ public void testJoinWithEmptyBuildSide()
"SELECT * FROM partitioned_lineitem JOIN supplier ON partitioned_lineitem.suppkey = supplier.suppkey AND supplier.name = 'abc'");
assertEquals(result.getResult().getRowCount(), 0);

OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), "tpch:" + PARTITIONED_LINEITEM);
assertEquals(probeStats.getInputPositions(), 0L);
assertEquals(probeStats.getDynamicFilterSplitsProcessed(), 0L);
// TODO bring back OperatorStats assertions from https://github.com/prestosql/presto/commit/1feaa0f928a02f577c8ac9ef6cc0c8ec2008a46d
// after https://github.com/prestosql/presto/issues/5120 is fixed

DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
Expand All @@ -125,11 +122,8 @@ public void testJoinWithSelectiveBuildSide()
"AND supplier.name = 'Supplier#000000001'");
assertGreaterThan(result.getResult().getRowCount(), 0);

OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), "tpch:" + PARTITIONED_LINEITEM);
// Probe-side is partially scanned
// TODO change to assertEquals after https://github.com/prestosql/presto/issues/5172
assertLessThanOrEqual(probeStats.getInputPositions(), 615L);
assertEquals(probeStats.getDynamicFilterSplitsProcessed(), 0L);
// TODO bring back OperatorStats assertions from https://github.com/prestosql/presto/commit/1feaa0f928a02f577c8ac9ef6cc0c8ec2008a46d
// after https://github.com/prestosql/presto/issues/5120 is fixed

DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
Expand All @@ -152,11 +146,8 @@ public void testJoinWithNonSelectiveBuildSide()
"SELECT * FROM partitioned_lineitem JOIN supplier ON partitioned_lineitem.suppkey = supplier.suppkey");
assertEquals(result.getResult().getRowCount(), LINEITEM_COUNT);

OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), "tpch:" + PARTITIONED_LINEITEM);
// Probe-side is fully scanned
// TODO change to assertEquals after https://github.com/prestosql/presto/issues/5172
assertLessThanOrEqual(probeStats.getInputPositions(), LINEITEM_COUNT);
assertEquals(probeStats.getDynamicFilterSplitsProcessed(), 0L);
// TODO bring back OperatorStats assertions from https://github.com/prestosql/presto/commit/1feaa0f928a02f577c8ac9ef6cc0c8ec2008a46d
// after https://github.com/prestosql/presto/issues/5120 is fixed

DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
Expand All @@ -181,11 +172,8 @@ public void testJoinLargeBuildSideNoDynamicFiltering()
"SELECT * FROM partitioned_lineitem JOIN orders ON partitioned_lineitem.orderkey = orders.orderkey");
assertEquals(result.getResult().getRowCount(), LINEITEM_COUNT);

OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), "tpch:" + PARTITIONED_LINEITEM);
// Probe-side is fully scanned because the build-side is too large for dynamic filtering
// TODO change to assertEquals after https://github.com/prestosql/presto/issues/5172
assertLessThanOrEqual(probeStats.getInputPositions(), LINEITEM_COUNT);
assertEquals(probeStats.getDynamicFilterSplitsProcessed(), 0L);
// TODO bring back OperatorStats assertions from https://github.com/prestosql/presto/commit/1feaa0f928a02f577c8ac9ef6cc0c8ec2008a46d
// after https://github.com/prestosql/presto/issues/5120 is fixed

DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
Expand All @@ -212,11 +200,8 @@ public void testJoinWithMultipleDynamicFiltersOnProbe()
") t JOIN supplier ON t.suppkey = supplier.suppkey AND supplier.suppkey IN (2, 3)");
assertGreaterThan(result.getResult().getRowCount(), 0);

OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), "tpch:" + PARTITIONED_LINEITEM);
// Probe-side is partially scanned
// TODO change to assertEquals after https://github.com/prestosql/presto/issues/5172
assertLessThanOrEqual(probeStats.getInputPositions(), 558L);
assertEquals(probeStats.getDynamicFilterSplitsProcessed(), 0L);
// TODO bring back OperatorStats assertions from https://github.com/prestosql/presto/commit/1feaa0f928a02f577c8ac9ef6cc0c8ec2008a46d
// after https://github.com/prestosql/presto/issues/5120 is fixed

DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 2L);
Expand All @@ -241,9 +226,8 @@ public void testSemiJoinWithEmptyBuildSide()
"SELECT * FROM partitioned_lineitem WHERE suppkey IN (SELECT suppkey FROM supplier WHERE name = 'abc')");
assertEquals(result.getResult().getRowCount(), 0);

OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), "tpch:" + PARTITIONED_LINEITEM);
assertEquals(probeStats.getInputPositions(), 0L);
assertEquals(probeStats.getDynamicFilterSplitsProcessed(), 0L);
// TODO bring back OperatorStats assertions from https://github.com/prestosql/presto/commit/0fb16ab9d9c990e58fad63d4dab3dbbe482a077d
// after https://github.com/prestosql/presto/issues/5120 is fixed

DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
Expand All @@ -266,11 +250,8 @@ public void testSemiJoinWithSelectiveBuildSide()
"SELECT * FROM partitioned_lineitem WHERE suppkey IN (SELECT suppkey FROM supplier WHERE name = 'Supplier#000000001')");
assertGreaterThan(result.getResult().getRowCount(), 0);

OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), "tpch:" + PARTITIONED_LINEITEM);
// Probe-side is partially scanned
// TODO change to assertEquals after https://github.com/prestosql/presto/issues/5172
assertLessThanOrEqual(probeStats.getInputPositions(), 615L);
assertEquals(probeStats.getDynamicFilterSplitsProcessed(), 0L);
// TODO bring back OperatorStats assertions from https://github.com/prestosql/presto/commit/0fb16ab9d9c990e58fad63d4dab3dbbe482a077d
// after https://github.com/prestosql/presto/issues/5120 is fixed

DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
Expand All @@ -293,11 +274,8 @@ public void testSemiJoinWithNonSelectiveBuildSide()
"SELECT * FROM partitioned_lineitem WHERE suppkey IN (SELECT suppkey FROM supplier)");
assertGreaterThan(result.getResult().getRowCount(), 0);

OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), "tpch:" + PARTITIONED_LINEITEM);
// Probe-side is fully scanned
// TODO change to assertEquals after https://github.com/prestosql/presto/issues/5172
assertLessThanOrEqual(probeStats.getInputPositions(), LINEITEM_COUNT);
assertEquals(probeStats.getDynamicFilterSplitsProcessed(), 0L);
// TODO bring back OperatorStats assertions from https://github.com/prestosql/presto/commit/0fb16ab9d9c990e58fad63d4dab3dbbe482a077d
// after https://github.com/prestosql/presto/issues/5120 is fixed

DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
Expand All @@ -322,11 +300,8 @@ public void testSemiJoinLargeBuildSideNoDynamicFiltering()
"SELECT * FROM partitioned_lineitem WHERE orderkey IN (SELECT orderkey FROM orders)");
assertEquals(result.getResult().getRowCount(), LINEITEM_COUNT);

OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), "tpch:" + PARTITIONED_LINEITEM);
// Probe-side is fully scanned because the build-side is too large for dynamic filtering
// TODO change to assertEquals after https://github.com/prestosql/presto/issues/5172
assertLessThanOrEqual(probeStats.getInputPositions(), LINEITEM_COUNT);
assertEquals(probeStats.getDynamicFilterSplitsProcessed(), 0L);
// TODO bring back OperatorStats assertions from https://github.com/prestosql/presto/commit/0fb16ab9d9c990e58fad63d4dab3dbbe482a077d
// after https://github.com/prestosql/presto/issues/5120 is fixed

DynamicFiltersStats dynamicFiltersStats = getDynamicFilteringStats(result.getQueryId());
assertEquals(dynamicFiltersStats.getTotalDynamicFilters(), 1L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
import java.util.Optional;
import java.util.OptionalLong;
import java.util.function.Consumer;
import java.util.function.Supplier;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
Expand All @@ -72,11 +71,9 @@
import static io.prestosql.SystemSessionProperties.JOIN_REORDERING_STRATEGY;
import static io.prestosql.sql.ParsingUtil.createParsingOptions;
import static io.prestosql.sql.SqlFormatter.formatSql;
import static io.prestosql.testing.assertions.Assert.assertEventually;
import static io.prestosql.transaction.TransactionBuilder.transaction;
import static java.lang.String.format;
import static java.util.Collections.emptyList;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
Expand Down Expand Up @@ -453,15 +450,13 @@ protected OperatorStats searchScanFilterAndProjectOperatorStats(QueryId queryId,
.findOnlyElement()
.getId();

Supplier<OperatorStats> operatorStatsSupplier = () -> runner.getCoordinator()
return runner.getCoordinator()
.getQueryManager()
.getFullQueryInfo(queryId)
.getQueryStats()
.getOperatorSummaries()
.stream()
.filter(summary -> nodeId.equals(summary.getPlanNodeId()) && summary.getOperatorType().equals("ScanFilterAndProjectOperator"))
.collect(MoreCollectors.onlyElement());
assertEventually(new Duration(5, SECONDS), operatorStatsSupplier::get);
return operatorStatsSupplier.get();
}
}

0 comments on commit 9faddbe

Please sign in to comment.