diff --git a/presto-main/src/main/java/com/facebook/presto/sql/planner/LocalExecutionPlanner.java b/presto-main/src/main/java/com/facebook/presto/sql/planner/LocalExecutionPlanner.java index 084f67264c74a..cd6e8e2134abb 100644 --- a/presto-main/src/main/java/com/facebook/presto/sql/planner/LocalExecutionPlanner.java +++ b/presto-main/src/main/java/com/facebook/presto/sql/planner/LocalExecutionPlanner.java @@ -1754,7 +1754,7 @@ public PhysicalOperation visitIndexJoin(IndexJoinNode node, LocalExecutionPlanCo } OperatorFactory lookupJoinOperatorFactory; - OptionalInt totalOperatorsCount = getJoinOperatorsCountForSpill(context, session); + OptionalInt totalOperatorsCount = OptionalInt.empty(); // spill not supported for index joins switch (node.getType()) { case INNER: lookupJoinOperatorFactory = lookupJoinOperators.innerJoin(context.getNextOperatorId(), node.getId(), lookupSourceFactoryManager, probeSource.getTypes(), probeChannels, probeHashChannel, Optional.empty(), totalOperatorsCount, partitioningSpillerFactory); diff --git a/presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestIndexedQueries.java b/presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestIndexedQueries.java index 5688f5c5c5f22..79a6344c70a0d 100644 --- a/presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestIndexedQueries.java +++ b/presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestIndexedQueries.java @@ -13,6 +13,7 @@ */ package com.facebook.presto.tests; +import com.facebook.presto.Session; import com.facebook.presto.testing.MaterializedResult; import com.facebook.presto.tests.tpch.TpchIndexSpec; import com.facebook.presto.tests.tpch.TpchIndexSpec.Builder; @@ -77,6 +78,26 @@ public void testBasicIndexJoin() " ON l.orderkey = o.orderkey"); } + @Test + public void testBasicIndexJoinWithSpillEnabled() + { + // spill is not supported for index join, but it shares the lookup join operator + // with non-index join. Make sure no errors are thrown when running index joins + // when spill is enabled. + assertQuery(Session.builder(getSession()) + .setSystemProperty("spill_enabled", "true") + .setSystemProperty("join_spill_enabled", "true") + .build(), + "" + + "SELECT *\n" + + "FROM (\n" + + " SELECT *\n" + + " FROM lineitem\n" + + " WHERE partkey % 8 = 0) l\n" + + "JOIN orders o\n" + + " ON l.orderkey = o.orderkey"); + } + @Test public void testBasicIndexJoinReverseCandidates() { diff --git a/presto-tests/src/test/java/com/facebook/presto/tests/TestDistributedQueriesIndexed.java b/presto-tests/src/test/java/com/facebook/presto/tests/TestDistributedQueriesIndexed.java index a11d1e3a4d511..31b7c51e077d6 100644 --- a/presto-tests/src/test/java/com/facebook/presto/tests/TestDistributedQueriesIndexed.java +++ b/presto-tests/src/test/java/com/facebook/presto/tests/TestDistributedQueriesIndexed.java @@ -15,6 +15,9 @@ import com.facebook.presto.Session; import com.facebook.presto.tests.tpch.IndexedTpchPlugin; +import com.google.common.collect.ImmutableMap; + +import java.nio.file.Paths; import static com.facebook.presto.testing.TestingSession.testSessionBuilder; import static com.facebook.presto.tpch.TpchMetadata.TINY_SCHEMA_NAME; @@ -35,7 +38,14 @@ private static DistributedQueryRunner createQueryRunner() .setSchema(TINY_SCHEMA_NAME) .build(); - DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 3); + // set spill path so we can enable spill by session property + ImmutableMap extraProperties = ImmutableMap.of( + "experimental.spiller-spill-path", + Paths.get(System.getProperty("java.io.tmpdir"), "presto", "spills").toString()); + DistributedQueryRunner queryRunner = new DistributedQueryRunner.Builder(session) + .setNodeCount(3) + .setExtraProperties(extraProperties) + .build(); queryRunner.installPlugin(new IndexedTpchPlugin(INDEX_SPEC)); queryRunner.createCatalog("tpch_indexed", "tpch_indexed"); diff --git a/presto-thrift-connector/src/test/java/com/facebook/presto/connector/thrift/integration/TestThriftDistributedQueriesIndexed.java b/presto-thrift-connector/src/test/java/com/facebook/presto/connector/thrift/integration/TestThriftDistributedQueriesIndexed.java index fd152b014fa9c..974a28183797c 100644 --- a/presto-thrift-connector/src/test/java/com/facebook/presto/connector/thrift/integration/TestThriftDistributedQueriesIndexed.java +++ b/presto-thrift-connector/src/test/java/com/facebook/presto/connector/thrift/integration/TestThriftDistributedQueriesIndexed.java @@ -16,6 +16,8 @@ import com.facebook.presto.tests.AbstractTestIndexedQueries; import com.google.common.collect.ImmutableMap; +import java.nio.file.Paths; + import static com.facebook.presto.connector.thrift.integration.ThriftQueryRunner.createThriftQueryRunner; public class TestThriftDistributedQueriesIndexed @@ -23,7 +25,12 @@ public class TestThriftDistributedQueriesIndexed { public TestThriftDistributedQueriesIndexed() { - super(() -> createThriftQueryRunner(2, 2, true, ImmutableMap.of())); + super(() -> createThriftQueryRunner( + 2, + 2, + true, + // set spill path so we can enable spill by session property + ImmutableMap.of("experimental.spiller-spill-path", Paths.get(System.getProperty("java.io.tmpdir"), "presto", "spills").toString()))); } @Override