Skip to content

Commit 0234230

Browse files
committed
Fix localexchange propertie when spill is enabled
1 parent 0c19d4f commit 0234230

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

presto-main/src/main/java/com/facebook/presto/sql/planner/optimizations/ActualProperties.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import static com.facebook.presto.sql.planner.optimizations.PartitioningUtils.isRepartitionEffective;
4848
import static com.facebook.presto.sql.planner.optimizations.PartitioningUtils.translatePartitioningRowExpression;
4949
import static com.facebook.presto.sql.planner.optimizations.PartitioningUtils.translateToCoalesce;
50-
import static com.facebook.presto.util.MoreLists.filteredCopy;
5150
import static com.google.common.base.MoreObjects.toStringHelper;
5251
import static com.google.common.base.Preconditions.checkArgument;
5352
import static com.google.common.collect.Iterables.transform;
@@ -323,7 +322,16 @@ public ActualProperties build()
323322
{
324323
List<LocalProperty<VariableReferenceExpression>> localProperties = this.localProperties;
325324
if (unordered) {
326-
localProperties = filteredCopy(this.localProperties, property -> !property.isOrderSensitive());
325+
ImmutableList.Builder<LocalProperty<VariableReferenceExpression>> newLocalProperties = ImmutableList.builder();
326+
for (LocalProperty<VariableReferenceExpression> property : this.localProperties) {
327+
if (!property.isOrderSensitive()) {
328+
newLocalProperties.add(property);
329+
}
330+
else {
331+
break;
332+
}
333+
}
334+
localProperties = newLocalProperties.build();
327335
}
328336
return new ActualProperties(global, localProperties, constants);
329337
}

presto-tests/src/test/java/com/facebook/presto/tests/TestDistributedSpilledQueries.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.facebook.presto.testing.QueryRunner;
1919
import com.facebook.presto.tpch.TpchPlugin;
2020
import com.google.common.collect.ImmutableMap;
21+
import org.intellij.lang.annotations.Language;
2122
import org.testng.annotations.Test;
2223

2324
import java.nio.file.Paths;
@@ -75,4 +76,21 @@ public void testAssignUniqueId()
7576
// TODO: disabled until https://github.com/prestodb/presto/issues/8926 is resolved
7677
// due to long running query test created many spill files on disk.
7778
}
79+
80+
@Test
81+
public void testQueriesWithSpill()
82+
{
83+
// Test double filtered left, right, full and inner joins with right constant equality.
84+
@Language("SQL") String query = "with t1 as (select max(totalprice) maxprice, min(totalprice) minprice, custkey ckey from orders group by custkey), " +
85+
"t2 as (select custkey, totalprice, (select maxprice from t1 where ckey = custkey) maxprice, " +
86+
"(select minprice from t1 where ckey=custkey) minprice from orders) select custkey from t2 where " +
87+
"(totalprice between minprice and maxprice) group by custkey";
88+
Session enableSpill = Session.builder(getSession())
89+
.setSystemProperty("spill_enabled", "true")
90+
.build();
91+
Session disableSpill = Session.builder(getSession())
92+
.setSystemProperty("spill_enabled", "true")
93+
.build();
94+
assertQueryWithSameQueryRunner(disableSpill, query, enableSpill);
95+
}
7896
}

0 commit comments

Comments
 (0)