This is an automated email from the ASF dual-hosted git repository.
siddteotia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new cef84f0737 [multisage] fix queries with LIMIT and no ORDER BY (#9498)
cef84f0737 is described below
commit cef84f0737fe4f207c3ed2dabad3bed17caf75c2
Author: Almog Gavra <[email protected]>
AuthorDate: Mon Oct 3 14:32:31 2022 -0700
[multisage] fix queries with LIMIT and no ORDER BY (#9498)
before this change, the optimizer would allow pushing down
of LIMIT clauses without any ORDER BY. This is a problem,
because it doesn't have any top-level LIMIT which would
limit the final results of the query. This PR fixes that
problem, and I will follow this up with another PR that
adds an additional SORT stage at the top level.
---
.../apache/calcite/rel/rules/PinotSortExchangeNodeInsertRule.java | 4 ++--
.../test/java/org/apache/pinot/query/runtime/QueryRunnerTest.java | 5 ++++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git
a/pinot-query-planner/src/main/java/org/apache/calcite/rel/rules/PinotSortExchangeNodeInsertRule.java
b/pinot-query-planner/src/main/java/org/apache/calcite/rel/rules/PinotSortExchangeNodeInsertRule.java
index 937728dd1e..fe57992074 100644
---
a/pinot-query-planner/src/main/java/org/apache/calcite/rel/rules/PinotSortExchangeNodeInsertRule.java
+++
b/pinot-query-planner/src/main/java/org/apache/calcite/rel/rules/PinotSortExchangeNodeInsertRule.java
@@ -29,7 +29,7 @@ import org.apache.calcite.tools.RelBuilderFactory;
/**
- * Special rule for Pinot, this rule is fixed to always insert exchange after
JOIN node.
+ * Special rule for Pinot, this rule is fixed to always insert exchange after
SORT node.
*/
public class PinotSortExchangeNodeInsertRule extends RelOptRule {
public static final PinotSortExchangeNodeInsertRule INSTANCE =
@@ -46,7 +46,7 @@ public class PinotSortExchangeNodeInsertRule extends
RelOptRule {
}
if (call.rel(0) instanceof Sort) {
Sort sort = call.rel(0);
- return sort.getCollation().getFieldCollations().size() > 0 &&
!PinotRuleUtils.isExchange(sort.getInput());
+ return !PinotRuleUtils.isExchange(sort.getInput());
}
return false;
}
diff --git
a/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/QueryRunnerTest.java
b/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/QueryRunnerTest.java
index e1f685a363..06fd707a26 100644
---
a/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/QueryRunnerTest.java
+++
b/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/QueryRunnerTest.java
@@ -150,9 +150,12 @@ public class QueryRunnerTest extends QueryRunnerTestBase {
// using join clause
new Object[]{"SELECT * FROM a JOIN b USING (col1)", 15},
+ // cannot compare with H2 w/o an ORDER BY because ordering is
indeterminate
+ new Object[]{"SELECT * FROM a LIMIT 2", 2},
+
// test dateTrunc
// - on leaf stage
- new Object[]{"SELECT dateTrunc('DAY', ts) FROM a LIMIT 10", 15},
+ new Object[]{"SELECT dateTrunc('DAY', ts) FROM a LIMIT 10", 10},
// - on intermediate stage
new Object[]{"SELECT dateTrunc('DAY', round(a.ts, b.ts)) FROM a JOIN b
"
+ "ON a.col1 = b.col1 AND a.col2 = b.col2", 15},
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]