Dmitry Lychagin has submitted this change and it was merged. Change subject: [ASTERIXDB-2424][COMP] No limit pushdown if multiple limit clauses ......................................................................
[ASTERIXDB-2424][COMP] No limit pushdown if multiple limit clauses - user model changes: no - storage format changes: no - interface changes: no Details: - CopyLimitDownRule should not stop at the first limit clause it processes Change-Id: Id92bb99c57d1363740b0ccbb09bceb59da968ca0 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2815 Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Taewoo Kim <wangs...@gmail.com> --- A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/push-limit-to-primary-scan-select/push-limit-to-primary-scan-select.5.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/results/limit/push-limit-to-primary-scan-select/push-limit-to-primary-scan-select.5.adm M hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/CopyLimitDownRule.java 3 files changed, 102 insertions(+), 2 deletions(-) Approvals: Anon. E. Moose #1000171: Taewoo Kim: Looks good to me, approved Jenkins: Verified; No violations found; ; Verified diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/push-limit-to-primary-scan-select/push-limit-to-primary-scan-select.5.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/push-limit-to-primary-scan-select/push-limit-to-primary-scan-select.5.query.sqlpp new file mode 100644 index 0000000..14393b4 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/push-limit-to-primary-scan-select/push-limit-to-primary-scan-select.5.query.sqlpp @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Description : Test limit push down when there're + * multiple limit clauses + * Expected Result : Success ("limit 1" is pushed to the scan) + */ + +use test; + +explain +select dblpid from DBLP1 d +where d.dblpid = ( + select * + from DBLP1 d + where ends_with(dblpid, "Blakeley95") + limit 1 +)[0].d.dblpid +limit 2 \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/limit/push-limit-to-primary-scan-select/push-limit-to-primary-scan-select.5.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/limit/push-limit-to-primary-scan-select/push-limit-to-primary-scan-select.5.adm new file mode 100644 index 0000000..b83be67 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/limit/push-limit-to-primary-scan-select/push-limit-to-primary-scan-select.5.adm @@ -0,0 +1,64 @@ +distribute result [$$31] +-- DISTRIBUTE_RESULT |UNPARTITIONED| + exchange + -- ONE_TO_ONE_EXCHANGE |UNPARTITIONED| + limit 2 + -- STREAM_LIMIT |UNPARTITIONED| + exchange + -- RANDOM_MERGE_EXCHANGE |PARTITIONED| + project ([$$31]) + -- STREAM_PROJECT |PARTITIONED| + assign [$$31] <- [{"dblpid": $$32}] + -- ASSIGN |PARTITIONED| + limit 2 + -- STREAM_LIMIT |PARTITIONED| + project ([$$32]) + -- STREAM_PROJECT |PARTITIONED| + exchange + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + join (eq($$32, $$35)) + -- HYBRID_HASH_JOIN [$$32][$$35] |PARTITIONED| + exchange + -- HASH_PARTITION_EXCHANGE [$$32] |PARTITIONED| + project ([$$32]) + -- STREAM_PROJECT |PARTITIONED| + assign [$$32] <- [$$d.getField(1)] + -- ASSIGN |PARTITIONED| + project ([$$d]) + -- STREAM_PROJECT |PARTITIONED| + exchange + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + data-scan []<-[$$33, $$d] <- test.DBLP1 + -- DATASOURCE_SCAN |PARTITIONED| + exchange + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + empty-tuple-source + -- EMPTY_TUPLE_SOURCE |PARTITIONED| + exchange + -- HASH_PARTITION_EXCHANGE [$$35] |PARTITIONED| + project ([$$35]) + -- STREAM_PROJECT |UNPARTITIONED| + assign [$$35] <- [get-item($$24, 0).getField(0).getField(1)] + -- ASSIGN |UNPARTITIONED| + aggregate [$$24] <- [listify($$23)] + -- AGGREGATE |UNPARTITIONED| + limit 1 + -- STREAM_LIMIT |UNPARTITIONED| + project ([$$23]) + -- STREAM_PROJECT |PARTITIONED| + exchange + -- SORT_MERGE_EXCHANGE [$$34(ASC) ] |PARTITIONED| + project ([$$34, $$23]) + -- STREAM_PROJECT |PARTITIONED| + assign [$$23] <- [{"d": $$d}] + -- ASSIGN |PARTITIONED| + limit 1 + -- STREAM_LIMIT |PARTITIONED| + exchange + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + data-scan []<-[$$34, $$d] <- test.DBLP1 condition (ends-with($$d.getField(1), "Blakeley95")) limit 1 + -- DATASOURCE_SCAN |PARTITIONED| + exchange + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + empty-tuple-source + -- EMPTY_TUPLE_SOURCE |PARTITIONED| diff --git a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/CopyLimitDownRule.java b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/CopyLimitDownRule.java index 4a224c8..7e36748 100644 --- a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/CopyLimitDownRule.java +++ b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/CopyLimitDownRule.java @@ -43,12 +43,12 @@ public class CopyLimitDownRule implements IAlgebraicRewriteRule { @Override - public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) { + public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) { return false; } @Override - public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) + public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (op.getOperatorTag() != LogicalOperatorTag.LIMIT) { -- To view, visit https://asterix-gerrit.ics.uci.edu/2815 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id92bb99c57d1363740b0ccbb09bceb59da968ca0 Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Dmitry Lychagin <dmitry.lycha...@couchbase.com> Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Dmitry Lychagin <dmitry.lycha...@couchbase.com> Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Gerrit-Reviewer: Taewoo Kim <wangs...@gmail.com> Gerrit-Reviewer: Till Westmann <ti...@apache.org> Gerrit-Reviewer: Xikui Wang <xkk...@gmail.com>