Dmitry Lychagin has submitted this change and it was merged. Change subject: [ASTERIXDB-2420][COMP] Internal error with limit clause ......................................................................
[ASTERIXDB-2420][COMP] Internal error with limit clause - user model changes: no - storage format changes: no - interface changes: no Details: - CopyLimitDownRule must not copy limit below clauses that produce that limit’s variables Change-Id: I6c77b7e24d6d0a95f3c772301d592c5b5c478119 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2805 Tested-by: Jenkins <[email protected]> Contrib: Jenkins <[email protected]> Integration-Tests: Jenkins <[email protected]> Reviewed-by: Taewoo Kim <[email protected]> --- A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.2.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.3.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/results/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.1.adm M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml M hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/CopyLimitDownRule.java 6 files changed, 100 insertions(+), 3 deletions(-) Approvals: Taewoo Kim: Looks good to me, approved Jenkins: Verified; ; Verified Objections: Anon. E. Moose #1000171: Violations found Jenkins: Violations found diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.1.ddl.sqlpp new file mode 100644 index 0000000..4f446c8 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.1.ddl.sqlpp @@ -0,0 +1,40 @@ +/* + * 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 push down limit + * Expected Result : Success + */ + +drop dataverse test if exists; +create dataverse test; + +use test; + +create type test.DBLPType as +{ + id : bigint, + dblpid : string, + title : string, + authors : string, + misc : string +}; + +create dataset DBLP1(DBLPType) primary key id; + diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.2.update.sqlpp new file mode 100644 index 0000000..867b825 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.2.update.sqlpp @@ -0,0 +1,22 @@ +/* + * 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. + */ + +use test; + +load dataset DBLP1 using localfs ((`path`=`asterix_nc1://data/dblp-small/dblp-small-id.txt`),(`format`=`delimited-text`),(`delimiter`=`:`)); diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.3.query.sqlpp new file mode 100644 index 0000000..8960f6b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.3.query.sqlpp @@ -0,0 +1,25 @@ +/* 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 pushdown + * Expected Result : Success + */ + +use test; + +select value t.id +from DBLP1 t +order by t.id +limit {"a":1}.a offset {"a":1}.a diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.1.adm new file mode 100644 index 0000000..d8263ee --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/limit/query-ASTERIXDB-2420/query-ASTERIXDB-2420.1.adm @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml index 16bf364..49bed4b 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml @@ -10197,6 +10197,11 @@ <output-dir compare="Text">push-limit-to-primary-lookup-select</output-dir> </compilation-unit> </test-case> + <test-case FilePath="limit"> + <compilation-unit name="query-ASTERIXDB-2420"> + <output-dir compare="Text">query-ASTERIXDB-2420</output-dir> + </compilation-unit> + </test-case> </test-group> &GeoQueries; </test-suite> 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 1eaf9c7..4a224c8 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 @@ -67,13 +67,17 @@ List<LogicalVariable> candidateProducedVars = new ArrayList<>(); while (true) { - candidateProducedVars.clear(); ILogicalOperator candidateOp = candidateOpRef.getValue(); LogicalOperatorTag candidateOpTag = candidateOp.getOperatorTag(); if (candidateOp.getInputs().size() > 1 || !candidateOp.isMap() || candidateOpTag == LogicalOperatorTag.SELECT || candidateOpTag == LogicalOperatorTag.LIMIT - || candidateOpTag == LogicalOperatorTag.UNNEST_MAP - || !OperatorPropertiesUtil.disjoint(limitUsedVars, candidateProducedVars)) { + || candidateOpTag == LogicalOperatorTag.UNNEST_MAP) { + break; + } + + candidateProducedVars.clear(); + VariableUtilities.getProducedVariables(candidateOp, candidateProducedVars); + if (!OperatorPropertiesUtil.disjoint(limitUsedVars, candidateProducedVars)) { break; } -- To view, visit https://asterix-gerrit.ics.uci.edu/2805 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6c77b7e24d6d0a95f3c772301d592c5b5c478119 Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Dmitry Lychagin <[email protected]> Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Dmitry Lychagin <[email protected]> Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Taewoo Kim <[email protected]> Gerrit-Reviewer: Till Westmann <[email protected]> Gerrit-Reviewer: Xikui Wang <[email protected]>
