This is an automated email from the ASF dual-hosted git repository. rongr 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 7132a2203f [multistage][bugfix] sort copy rule to always push limit when no collation (#12251) 7132a2203f is described below commit 7132a2203f13478f450cbf8f0524ba72bdc267b7 Author: Rong Rong <ro...@apache.org> AuthorDate: Wed Jan 10 11:13:08 2024 -0800 [multistage][bugfix] sort copy rule to always push limit when no collation (#12251) Co-authored-by: Rong Rong <ro...@startree.ai> --- .../apache/calcite/rel/rules/PinotSortExchangeCopyRule.java | 3 ++- .../src/test/resources/queries/OrderByPlans.json | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pinot-query-planner/src/main/java/org/apache/calcite/rel/rules/PinotSortExchangeCopyRule.java b/pinot-query-planner/src/main/java/org/apache/calcite/rel/rules/PinotSortExchangeCopyRule.java index 891db2d1ec..86310fc7e0 100644 --- a/pinot-query-planner/src/main/java/org/apache/calcite/rel/rules/PinotSortExchangeCopyRule.java +++ b/pinot-query-planner/src/main/java/org/apache/calcite/rel/rules/PinotSortExchangeCopyRule.java @@ -89,7 +89,8 @@ public class PinotSortExchangeCopyRule extends RelRule<RelRule.Config> { fetch = REX_BUILDER.makeLiteral(total, TYPE_FACTORY.createSqlType(SqlTypeName.INTEGER)); } // do not transform sort-exchange copy when there's no fetch limit, or fetch amount is larger than threshold - if (fetch == null || RexExpressionUtils.getValueAsInt(fetch) > DEFAULT_SORT_EXCHANGE_COPY_THRESHOLD) { + if (!collation.getFieldCollations().isEmpty() + && (fetch == null || RexExpressionUtils.getValueAsInt(fetch) > DEFAULT_SORT_EXCHANGE_COPY_THRESHOLD)) { return; } diff --git a/pinot-query-planner/src/test/resources/queries/OrderByPlans.json b/pinot-query-planner/src/test/resources/queries/OrderByPlans.json index 153f587feb..dbe27dcff1 100644 --- a/pinot-query-planner/src/test/resources/queries/OrderByPlans.json +++ b/pinot-query-planner/src/test/resources/queries/OrderByPlans.json @@ -49,6 +49,18 @@ "\n" ] }, + { + "description": "Select * with super large limit", + "sql": "EXPLAIN PLAN FOR SELECT * FROM b LIMIT 10000000", + "output": [ + "Execution Plan", + "\nLogicalSort(offset=[0], fetch=[10000000])", + "\n PinotLogicalSortExchange(distribution=[hash], collation=[[]], isSortOnSender=[false], isSortOnReceiver=[false])", + "\n LogicalSort(fetch=[10000000])", + "\n LogicalTableScan(table=[[b]])", + "\n" + ] + }, { "description": "Select * order by on 2 columns with super large limit", "sql": "EXPLAIN PLAN FOR SELECT * FROM b ORDER BY col1, col2 DESC LIMIT 10000000", --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org