Return-Path: X-Original-To: apmail-asterixdb-commits-archive@minotaur.apache.org Delivered-To: apmail-asterixdb-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D1E6F18155 for ; Tue, 16 Feb 2016 21:04:36 +0000 (UTC) Received: (qmail 5855 invoked by uid 500); 16 Feb 2016 21:04:36 -0000 Delivered-To: apmail-asterixdb-commits-archive@asterixdb.apache.org Received: (qmail 5819 invoked by uid 500); 16 Feb 2016 21:04:36 -0000 Mailing-List: contact commits-help@asterixdb.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.incubator.apache.org Delivered-To: mailing list commits@asterixdb.incubator.apache.org Received: (qmail 5809 invoked by uid 99); 16 Feb 2016 21:04:36 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Feb 2016 21:04:36 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 52950C0887 for ; Tue, 16 Feb 2016 21:04:36 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.549 X-Spam-Level: X-Spam-Status: No, score=-3.549 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.329] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id caH2e72-p434 for ; Tue, 16 Feb 2016 21:04:32 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with SMTP id 4EE995FE45 for ; Tue, 16 Feb 2016 21:04:31 +0000 (UTC) Received: (qmail 5780 invoked by uid 99); 16 Feb 2016 21:04:30 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Feb 2016 21:04:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 72AADE08CD; Tue, 16 Feb 2016 21:04:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: wangsaeu@apache.org To: commits@asterixdb.incubator.apache.org Message-Id: <9be3e337ebad4aafbcd5cbdfcdf01537@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-asterixdb git commit: ASTERIXDB-1231, ASTERIXDB-636: fixed Self-join Date: Tue, 16 Feb 2016 21:04:30 +0000 (UTC) Repository: incubator-asterixdb Updated Branches: refs/heads/master d33d3d1a6 -> 0c8e22d4d ASTERIXDB-1231, ASTERIXDB-636: fixed Self-join - Fixed self-join with index-out-of-boud exception during the compilation - Added a test case for ASTERIXDB-636 Change-Id: I8d5d9cb0cb54473fbe7a5e43934e9608548c1dbb Reviewed-on: https://asterix-gerrit.ics.uci.edu/635 Tested-by: Jenkins Reviewed-by: Yingyi Bu Project: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/commit/0c8e22d4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/tree/0c8e22d4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/diff/0c8e22d4 Branch: refs/heads/master Commit: 0c8e22d4d2b2f98310250d7a90d108d18cb662a7 Parents: d33d3d1 Author: Taewoo Kim Authored: Tue Feb 16 12:29:02 2016 -0800 Committer: Taewoo Kim Committed: Tue Feb 16 12:59:23 2016 -0800 ---------------------------------------------------------------------- .../am/AbstractIntroduceAccessMethodRule.java | 36 ++++++++---- .../metadata_selfjoin.1.ddl.aql | 27 +++++++++ .../metadata_selfjoin.2.update.aql | 24 ++++++++ .../metadata_selfjoin.3.query.aql | 32 +++++++++++ .../metadata_selfjoin/metadata_selfjoin.1.adm | 13 +++++ .../src/test/resources/metadata/testsuite.xml | 5 ++ .../orderby_limit_02/orderby_limit_02.1.ddl.aql | 36 ++++++++++++ .../orderby_limit_02.2.update.aql | 60 ++++++++++++++++++++ .../orderby_limit_02.3.query.aql | 33 +++++++++++ .../orderby_limit_02/orderby_limit_02.1.adm | 5 ++ .../src/test/resources/runtimets/testsuite.xml | 5 ++ 11 files changed, 266 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0c8e22d4/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java ---------------------------------------------------------------------- diff --git a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java index 1531b8a..cabc1e3 100644 --- a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java +++ b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java @@ -168,8 +168,8 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew // LENGTH_PARTITIONED_NGRAM_INVIX] IAccessMethod chosenAccessMethod = amEntry.getKey(); Index chosenIndex = indexEntry.getKey(); - boolean isKeywordOrNgramIndexChosen = - chosenIndex.getIndexType() == IndexType.LENGTH_PARTITIONED_WORD_INVIX + boolean isKeywordOrNgramIndexChosen = chosenIndex + .getIndexType() == IndexType.LENGTH_PARTITIONED_WORD_INVIX || chosenIndex.getIndexType() == IndexType.LENGTH_PARTITIONED_NGRAM_INVIX || chosenIndex.getIndexType() == IndexType.SINGLE_PARTITION_WORD_INVIX || chosenIndex.getIndexType() == IndexType.SINGLE_PARTITION_NGRAM_INVIX; @@ -185,7 +185,6 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew return result; } - /** * Removes irrelevant access methods candidates, based on whether the * expressions in the query match those in the index. For example, some @@ -574,16 +573,33 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew // The variable value is one of the partitioning fields. List fieldName = null; IAType fieldType = null; + List> subTreePKs = null; if (!fromAdditionalDataSource) { - fieldName = DatasetUtils.getPartitioningKeys(subTree.dataset).get(varIndex); - fieldType = (IAType) context.getOutputTypeEnvironment(subTree.dataSourceRef.getValue()).getVarType(var); + subTreePKs = DatasetUtils.getPartitioningKeys(subTree.dataset); + // Check whether this variable is PK, not a record variable. + if (varIndex <= subTreePKs.size() - 1) { + fieldName = subTreePKs.get(varIndex); + fieldType = (IAType) context.getOutputTypeEnvironment(subTree.dataSourceRef.getValue()) + .getVarType(var); + } } else { - fieldName = DatasetUtils.getPartitioningKeys(subTree.ixJoinOuterAdditionalDatasets.get(varIndex)) - .get(varIndex); - fieldType = (IAType) context - .getOutputTypeEnvironment(subTree.ixJoinOuterAdditionalDataSourceRefs.get(varIndex).getValue()) - .getVarType(var); + // Need to check additional dataset one by one + for (int i = 0; i < subTree.ixJoinOuterAdditionalDatasets.size(); i++) { + if (subTree.ixJoinOuterAdditionalDatasets.get(i) != null) { + subTreePKs = DatasetUtils.getPartitioningKeys(subTree.ixJoinOuterAdditionalDatasets.get(i)); + + // Check whether this variable is PK, not a record variable. + if (subTreePKs.contains(var) && varIndex <= subTreePKs.size() - 1) { + fieldName = subTreePKs.get(varIndex); + fieldType = (IAType) context + .getOutputTypeEnvironment( + subTree.ixJoinOuterAdditionalDataSourceRefs.get(i).getValue()) + .getVarType(var); + break; + } + } + } } // Set the fieldName in the corresponding matched function // expression, and remember matching subtree. http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0c8e22d4/asterix-app/src/test/resources/metadata/queries/basic/metadata_selfjoin/metadata_selfjoin.1.ddl.aql ---------------------------------------------------------------------- diff --git a/asterix-app/src/test/resources/metadata/queries/basic/metadata_selfjoin/metadata_selfjoin.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/basic/metadata_selfjoin/metadata_selfjoin.1.ddl.aql new file mode 100644 index 0000000..1a690a1 --- /dev/null +++ b/asterix-app/src/test/resources/metadata/queries/basic/metadata_selfjoin/metadata_selfjoin.1.ddl.aql @@ -0,0 +1,27 @@ +/* + * 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 : Checks whether a meta-data self-join query works or not. + * Expected Res : Success + * Issue : ASTERIXDB-1231 + */ + +drop dataverse testdv if exists; +drop dataverse test if exists; http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0c8e22d4/asterix-app/src/test/resources/metadata/queries/basic/metadata_selfjoin/metadata_selfjoin.2.update.aql ---------------------------------------------------------------------- diff --git a/asterix-app/src/test/resources/metadata/queries/basic/metadata_selfjoin/metadata_selfjoin.2.update.aql b/asterix-app/src/test/resources/metadata/queries/basic/metadata_selfjoin/metadata_selfjoin.2.update.aql new file mode 100644 index 0000000..15bf59a --- /dev/null +++ b/asterix-app/src/test/resources/metadata/queries/basic/metadata_selfjoin/metadata_selfjoin.2.update.aql @@ -0,0 +1,24 @@ +/* + * 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 : Checks whether a meta-data self-join query works or not. + * Expected Res : Success + * Issue : ASTERIXDB-1231 + */ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0c8e22d4/asterix-app/src/test/resources/metadata/queries/basic/metadata_selfjoin/metadata_selfjoin.3.query.aql ---------------------------------------------------------------------- diff --git a/asterix-app/src/test/resources/metadata/queries/basic/metadata_selfjoin/metadata_selfjoin.3.query.aql b/asterix-app/src/test/resources/metadata/queries/basic/metadata_selfjoin/metadata_selfjoin.3.query.aql new file mode 100644 index 0000000..569d3d1 --- /dev/null +++ b/asterix-app/src/test/resources/metadata/queries/basic/metadata_selfjoin/metadata_selfjoin.3.query.aql @@ -0,0 +1,32 @@ +/* + * 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 : Checks whether a meta-data self-join query works or not. + * Expected Res : Success + * Issue : ASTERIXDB-1231 + */ + +use dataverse Metadata; + +for $m in dataset Metadata.Dataset +for $n in dataset Metadata.Dataset +where $m=$n +return +{ "dv1": $m.DataverseName, "dv2": $n.DataverseName } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0c8e22d4/asterix-app/src/test/resources/metadata/results/basic/metadata_selfjoin/metadata_selfjoin.1.adm ---------------------------------------------------------------------- diff --git a/asterix-app/src/test/resources/metadata/results/basic/metadata_selfjoin/metadata_selfjoin.1.adm b/asterix-app/src/test/resources/metadata/results/basic/metadata_selfjoin/metadata_selfjoin.1.adm new file mode 100644 index 0000000..da05a15 --- /dev/null +++ b/asterix-app/src/test/resources/metadata/results/basic/metadata_selfjoin/metadata_selfjoin.1.adm @@ -0,0 +1,13 @@ +{ "dv1": "Metadata", "dv2": "Metadata" } +{ "dv1": "Metadata", "dv2": "Metadata" } +{ "dv1": "Metadata", "dv2": "Metadata" } +{ "dv1": "Metadata", "dv2": "Metadata" } +{ "dv1": "Metadata", "dv2": "Metadata" } +{ "dv1": "Metadata", "dv2": "Metadata" } +{ "dv1": "Metadata", "dv2": "Metadata" } +{ "dv1": "Metadata", "dv2": "Metadata" } +{ "dv1": "Metadata", "dv2": "Metadata" } +{ "dv1": "Metadata", "dv2": "Metadata" } +{ "dv1": "Metadata", "dv2": "Metadata" } +{ "dv1": "Metadata", "dv2": "Metadata" } +{ "dv1": "Metadata", "dv2": "Metadata" } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0c8e22d4/asterix-app/src/test/resources/metadata/testsuite.xml ---------------------------------------------------------------------- diff --git a/asterix-app/src/test/resources/metadata/testsuite.xml b/asterix-app/src/test/resources/metadata/testsuite.xml index 0b8c26a..bba2ab0 100644 --- a/asterix-app/src/test/resources/metadata/testsuite.xml +++ b/asterix-app/src/test/resources/metadata/testsuite.xml @@ -274,6 +274,11 @@ + + metadata_selfjoin + + + temp_dataset http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0c8e22d4/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_02/orderby_limit_02.1.ddl.aql ---------------------------------------------------------------------- diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_02/orderby_limit_02.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_02/orderby_limit_02.1.ddl.aql new file mode 100644 index 0000000..33722e7 --- /dev/null +++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_02/orderby_limit_02.1.ddl.aql @@ -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 : Range search query with LIMIT (and ORDER BY) should work fine. + * Issue : ASTERIXDB-636 + * Expected Result : Success + * + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +create type Emp as open +{ id : int32, name: string, salary: int32 } + +create dataset Employee(Emp) primary key id; + +create index idx-02 on Employee(name); http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0c8e22d4/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_02/orderby_limit_02.2.update.aql ---------------------------------------------------------------------- diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_02/orderby_limit_02.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_02/orderby_limit_02.2.update.aql new file mode 100644 index 0000000..d0b363f --- /dev/null +++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_02/orderby_limit_02.2.update.aql @@ -0,0 +1,60 @@ +/* + * 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 : Range search query with LIMIT (and ORDER BY) should work fine. + * Issue : ASTERIXDB-636 + * Expected Result : Success + * + */ + + +use dataverse test; + +insert into dataset Employee ( + {"id":123,"name":"Kevin","salary":10000} +); + +insert into dataset Employee ( + {"id":13,"name":"John","salary":5000} +); + +insert into dataset Employee ( + {"id":23,"name":"Susan","salary":7500} +); + +insert into dataset Employee ( + {"id":12,"name":"Smith","salary":4000} +); + +insert into dataset Employee ( + {"id":113,"name":"Roger","salary":8000} +); + +insert into dataset Employee ( + {"id":143,"name":"Raj","salary":6000} +); + +insert into dataset Employee ( + {"id":149,"name":"Ramesh","salary":5000} +); + +insert into dataset Employee ( + {"id":240,"name":"Ravi","salary":6500} +); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0c8e22d4/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_02/orderby_limit_02.3.query.aql ---------------------------------------------------------------------- diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_02/orderby_limit_02.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_02/orderby_limit_02.3.query.aql new file mode 100644 index 0000000..93288aa --- /dev/null +++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_02/orderby_limit_02.3.query.aql @@ -0,0 +1,33 @@ +/* + * 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 : Range search query with LIMIT (and ORDER BY) should work fine. + * Issue : ASTERIXDB-636 + * Expected Result : Success + * + */ + +use dataverse test; + +for $l in dataset Employee +where $l.name >= "A" and $l.name <= "Z" +limit 5 +order by $l.name desc +return {"name": $l.name} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0c8e22d4/asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_02/orderby_limit_02.1.adm ---------------------------------------------------------------------- diff --git a/asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_02/orderby_limit_02.1.adm b/asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_02/orderby_limit_02.1.adm new file mode 100644 index 0000000..e027c88 --- /dev/null +++ b/asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_02/orderby_limit_02.1.adm @@ -0,0 +1,5 @@ +{ "name": "Susan" } +{ "name": "Smith" } +{ "name": "Roger" } +{ "name": "Kevin" } +{ "name": "John" } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0c8e22d4/asterix-app/src/test/resources/runtimets/testsuite.xml ---------------------------------------------------------------------- diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml index 48dcbb4..bcc80ad 100644 --- a/asterix-app/src/test/resources/runtimets/testsuite.xml +++ b/asterix-app/src/test/resources/runtimets/testsuite.xml @@ -4306,6 +4306,11 @@ + + orderby_limit_02 + + + orderby_limit_offset_01