This is an automated email from the ASF dual-hosted git repository. mblow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 41212d67452fb92ad5a78a9ae92ad0aeba5b24ae Author: Peeyush Gupta <[email protected]> AuthorDate: Wed Dec 20 13:47:06 2023 -0800 [ASTERIXDB-3334][COMP] Incorrect answer on query - user model changes: no - storage format changes: no - interface changes: no Details: The wrong order of keys was getting used to do the partitioning for the hybrid hash join. Change-Id: I76c0c51e8e5243ea58a029dee8e7418292742ca6 Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18020 Reviewed-by: Ali Alsuliman <[email protected]> Integration-Tests: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> --- .../optimizerts/queries/query-ASTERIXDB-3334.sqlpp | 55 +++++++++ .../optimizerts/results/query-ASTERIXDB-3334.plan | 61 ++++++++++ .../results_cbo/query-ASTERIXDB-3334.plan | 61 ++++++++++ .../query-ASTERIXDB-3334.1.ddl.sqlpp | 46 +++++++ .../query-ASTERIXDB-3334.2.update.sqlpp | 132 +++++++++++++++++++++ .../query-ASTERIXDB-3334.3.query.sqlpp | 37 ++++++ .../query-ASTERIXDB-3334.3.adm | 1 + .../test/resources/runtimets/testsuite_sqlpp.xml | 5 + .../properties/UnorderedPartitionedProperty.java | 10 +- 9 files changed, 404 insertions(+), 4 deletions(-) diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/query-ASTERIXDB-3334.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/query-ASTERIXDB-3334.sqlpp new file mode 100644 index 0000000000..c21b569922 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/query-ASTERIXDB-3334.sqlpp @@ -0,0 +1,55 @@ +/* + * 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. + */ + +drop dataverse test if exists; +create dataverse test; + +use test; + +create type dt1 as {Id:int}; +create dataset collection0(dt1) primary key Id; + +CREATE VIEW `Staples`( +`Item Count` BIGINT NOT UNKNOWN, `Ship Priority` STRING NOT UNKNOWN, `Order Priority` STRING NOT UNKNOWN, +`Order Status` STRING NOT UNKNOWN, `Order Quantity` DOUBLE NOT UNKNOWN, `Sales Total` DOUBLE NOT UNKNOWN, +`Discount` DOUBLE NOT UNKNOWN, `Tax Rate` DOUBLE NOT UNKNOWN, `Ship Mode` STRING NOT UNKNOWN, `Fill Time` DOUBLE NOT UNKNOWN, +`Gross Profit` DOUBLE NOT UNKNOWN, `Price` DOUBLE NOT UNKNOWN, `Ship Handle Cost` DOUBLE NOT UNKNOWN, `Employee Name` STRING NOT UNKNOWN, +`Employee Dept` STRING NOT UNKNOWN, `Manager Name` STRING NOT UNKNOWN, `Employee Yrs Exp` DOUBLE NOT UNKNOWN, `Employee Salary` DOUBLE NOT UNKNOWN, +`Customer Name` STRING NOT UNKNOWN, `Customer State` STRING NOT UNKNOWN, `Call Center Region` STRING NOT UNKNOWN, `Customer Balance` DOUBLE NOT UNKNOWN, +`Customer Segment` STRING NOT UNKNOWN, `Prod Type1` STRING NOT UNKNOWN, `Prod Type2` STRING NOT UNKNOWN, `Prod Type3` STRING NOT UNKNOWN, +`Prod Type4` STRING NOT UNKNOWN, `Product Name` STRING NOT UNKNOWN, `Product Container` STRING NOT UNKNOWN, `Ship Promo` STRING NOT UNKNOWN, +`Supplier Name` STRING NOT UNKNOWN, `Supplier Balance` DOUBLE NOT UNKNOWN, `Supplier Region` STRING NOT UNKNOWN, `Supplier State` STRING NOT UNKNOWN, +`Order ID` STRING NOT UNKNOWN, `Order Year` BIGINT NOT UNKNOWN, `Order Month` BIGINT NOT UNKNOWN, `Order Day` BIGINT NOT UNKNOWN, +`Order Date` DATETIME NOT UNKNOWN, `Order Quarter` STRING NOT UNKNOWN, `Product Base Margin` DOUBLE NOT UNKNOWN, `Product ID` STRING NOT UNKNOWN, +`Receive Time` DOUBLE NOT UNKNOWN, `Received Date` DATETIME NOT UNKNOWN, `Ship Date` DATETIME NOT UNKNOWN, `Ship Charge` DOUBLE NOT UNKNOWN, +`Total Cycle Time` DOUBLE NOT UNKNOWN, `Product In Stock` STRING NOT UNKNOWN, `PID` BIGINT NOT UNKNOWN, `Market Segment` STRING NOT UNKNOWN) +default NULL AS `collection0`; + +SELECT `Staples`.`Employee Name` AS `Employee Name`, + AVG(`Staples`.`Employee Salary`) AS `avg:Employee Salary:ok` +FROM `Staples` `Staples` + INNER JOIN ( + SELECT `Staples`.`Call Center Region` AS `Call Center Region`, + `Staples`.`Employee Name` AS `Employee Name` + FROM `Staples` `Staples` + GROUP BY `Staples`.`Call Center Region`, + `Staples`.`Employee Name` + HAVING ((AVG(`Staples`.`Employee Salary`)>=102499.99999999898) AND (AVG(`Staples`.`Employee Salary`)<=110000.00000000111)) +) `t0` ON ((`Staples`.`Call Center Region` = `t0`.`Call Center Region`) AND (`Staples`.`Employee Name` = `t0`.`Employee Name`)) +GROUP BY `Staples`.`Employee Name`; diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/query-ASTERIXDB-3334.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/query-ASTERIXDB-3334.plan new file mode 100644 index 0000000000..bbb94e357a --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/query-ASTERIXDB-3334.plan @@ -0,0 +1,61 @@ +-- DISTRIBUTE_RESULT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- SORT_GROUP_BY[$$1112] |PARTITIONED| + { + -- AGGREGATE |LOCAL| + -- NESTED_TUPLE_SOURCE |LOCAL| + } + -- HASH_PARTITION_EXCHANGE [$$1112] |PARTITIONED| + -- SORT_GROUP_BY[$$1113] |PARTITIONED| + { + -- AGGREGATE |LOCAL| + -- NESTED_TUPLE_SOURCE |LOCAL| + } + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- HYBRID_HASH_JOIN [$$1113, $$1114][$$Employee Name, $$Call Center Region] |PARTITIONED| + -- HASH_PARTITION_EXCHANGE [$$1114, $$1113] |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- STREAM_SELECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- REPLICATE |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- DATASOURCE_SCAN (test.collection0) |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- EMPTY_TUPLE_SOURCE |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- STREAM_SELECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- SORT_GROUP_BY[$$1109, $$1110] |PARTITIONED| + { + -- AGGREGATE |LOCAL| + -- NESTED_TUPLE_SOURCE |LOCAL| + } + -- HASH_PARTITION_EXCHANGE [$$1109, $$1110] |PARTITIONED| + -- SORT_GROUP_BY[$$1117, $$1116] |PARTITIONED| + { + -- AGGREGATE |LOCAL| + -- NESTED_TUPLE_SOURCE |LOCAL| + } + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- STREAM_SELECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- REPLICATE |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- DATASOURCE_SCAN (test.collection0) |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- EMPTY_TUPLE_SOURCE |PARTITIONED| diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/query-ASTERIXDB-3334.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/query-ASTERIXDB-3334.plan new file mode 100644 index 0000000000..bbb94e357a --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/query-ASTERIXDB-3334.plan @@ -0,0 +1,61 @@ +-- DISTRIBUTE_RESULT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- SORT_GROUP_BY[$$1112] |PARTITIONED| + { + -- AGGREGATE |LOCAL| + -- NESTED_TUPLE_SOURCE |LOCAL| + } + -- HASH_PARTITION_EXCHANGE [$$1112] |PARTITIONED| + -- SORT_GROUP_BY[$$1113] |PARTITIONED| + { + -- AGGREGATE |LOCAL| + -- NESTED_TUPLE_SOURCE |LOCAL| + } + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- HYBRID_HASH_JOIN [$$1113, $$1114][$$Employee Name, $$Call Center Region] |PARTITIONED| + -- HASH_PARTITION_EXCHANGE [$$1114, $$1113] |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- STREAM_SELECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- REPLICATE |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- DATASOURCE_SCAN (test.collection0) |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- EMPTY_TUPLE_SOURCE |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- STREAM_SELECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- SORT_GROUP_BY[$$1109, $$1110] |PARTITIONED| + { + -- AGGREGATE |LOCAL| + -- NESTED_TUPLE_SOURCE |LOCAL| + } + -- HASH_PARTITION_EXCHANGE [$$1109, $$1110] |PARTITIONED| + -- SORT_GROUP_BY[$$1117, $$1116] |PARTITIONED| + { + -- AGGREGATE |LOCAL| + -- NESTED_TUPLE_SOURCE |LOCAL| + } + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- STREAM_SELECT |PARTITIONED| + -- ASSIGN |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- REPLICATE |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- STREAM_PROJECT |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- DATASOURCE_SCAN (test.collection0) |PARTITIONED| + -- ONE_TO_ONE_EXCHANGE |PARTITIONED| + -- EMPTY_TUPLE_SOURCE |PARTITIONED| diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3334/query-ASTERIXDB-3334.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3334/query-ASTERIXDB-3334.1.ddl.sqlpp new file mode 100644 index 0000000000..ac587d4595 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3334/query-ASTERIXDB-3334.1.ddl.sqlpp @@ -0,0 +1,46 @@ +/* + * 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: This test case is to verify the fix for ASTERIXDB-2947 + */ + +drop dataverse test if exists; +create dataverse test; + +use test; + +create type dt1 as {Id:int}; +create dataset collection0(dt1) primary key Id; + +CREATE VIEW `Staples`( +`Item Count` BIGINT NOT UNKNOWN, `Ship Priority` STRING NOT UNKNOWN, `Order Priority` STRING NOT UNKNOWN, +`Order Status` STRING NOT UNKNOWN, `Order Quantity` DOUBLE NOT UNKNOWN, `Sales Total` DOUBLE NOT UNKNOWN, +`Discount` DOUBLE NOT UNKNOWN, `Tax Rate` DOUBLE NOT UNKNOWN, `Ship Mode` STRING NOT UNKNOWN, `Fill Time` DOUBLE NOT UNKNOWN, +`Gross Profit` DOUBLE NOT UNKNOWN, `Price` DOUBLE NOT UNKNOWN, `Ship Handle Cost` DOUBLE NOT UNKNOWN, `Employee Name` STRING NOT UNKNOWN, +`Employee Dept` STRING NOT UNKNOWN, `Manager Name` STRING NOT UNKNOWN, `Employee Yrs Exp` DOUBLE NOT UNKNOWN, `Employee Salary` DOUBLE NOT UNKNOWN, +`Customer Name` STRING NOT UNKNOWN, `Customer State` STRING NOT UNKNOWN, `Call Center Region` STRING NOT UNKNOWN, `Customer Balance` DOUBLE NOT UNKNOWN, +`Customer Segment` STRING NOT UNKNOWN, `Prod Type1` STRING NOT UNKNOWN, `Prod Type2` STRING NOT UNKNOWN, `Prod Type3` STRING NOT UNKNOWN, +`Prod Type4` STRING NOT UNKNOWN, `Product Name` STRING NOT UNKNOWN, `Product Container` STRING NOT UNKNOWN, `Ship Promo` STRING NOT UNKNOWN, +`Supplier Name` STRING NOT UNKNOWN, `Supplier Balance` DOUBLE NOT UNKNOWN, `Supplier Region` STRING NOT UNKNOWN, `Supplier State` STRING NOT UNKNOWN, +`Order ID` STRING NOT UNKNOWN, `Order Year` BIGINT NOT UNKNOWN, `Order Month` BIGINT NOT UNKNOWN, `Order Day` BIGINT NOT UNKNOWN, +`Order Date` DATETIME NOT UNKNOWN, `Order Quarter` STRING NOT UNKNOWN, `Product Base Margin` DOUBLE NOT UNKNOWN, `Product ID` STRING NOT UNKNOWN, +`Receive Time` DOUBLE NOT UNKNOWN, `Received Date` DATETIME NOT UNKNOWN, `Ship Date` DATETIME NOT UNKNOWN, `Ship Charge` DOUBLE NOT UNKNOWN, +`Total Cycle Time` DOUBLE NOT UNKNOWN, `Product In Stock` STRING NOT UNKNOWN, `PID` BIGINT NOT UNKNOWN, `Market Segment` STRING NOT UNKNOWN) +default NULL AS `collection0` diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3334/query-ASTERIXDB-3334.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3334/query-ASTERIXDB-3334.2.update.sqlpp new file mode 100644 index 0000000000..c971b279d9 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3334/query-ASTERIXDB-3334.2.update.sqlpp @@ -0,0 +1,132 @@ +/* + * 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; + +insert into collection0 +([ + { + "Id": 1, + "Item Count": 1, + "Ship Priority": "0", + "Order Priority": "1-URGENT", + "Order Status": "F", + "Order Quantity": 38, + "Sales Total": 195.19, + "Discount": 0.08, + "Tax Rate": 0.03, + "Ship Mode": "REGULAR AIR", + "Fill Time": 2, + "Gross Profit": -71.33, + "Price": 5.28, + "Ship Handle Cost": 5.06, + "Employee Name": "Purkey, Jan", + "Employee Dept": "1054", + "Manager Name": "Collins, Babs", + "Employee Yrs Exp": 6, + "Employee Salary": 104677, + "Customer Name": "Roy Skaria", + "Customer State": "OHIO", + "Call Center Region": "CENTRAL", + "Customer Balance": 6496, + "Customer Segment": "CONSUMER", + "Prod Type1": "OFFICE SUPPLIES", + "Prod Type2": "PAPER", + "Prod Type3": "STATIONARY", + "Prod Type4": "BUSINESS STATIONARY", + "Product Name": "Astroparche® Fine Business Paper", + "Product Container": "SMALL BOX", + "Ship Promo": "REGULAR SHIPPING", + "Supplier Name": "Supplier_098", + "Supplier Balance": 5873, + "Supplier Region": "WEST", + "Supplier State": "CALIFORNIA", + "Order ID": "21284", + "Order Year": 1997, + "Order Month": 9, + "Order Day": 15, + "Order Date": "1997-09-15T00:00:00.000", + "Order Quarter": "Q3", + "Product Base Margin": 0.37, + "Product ID": "1811", + "Receive Time": 3, + "Received Date": "1997-09-20T00:00:00.000", + "Ship Date": "1997-09-17T00:00:00.000", + "Ship Charge": 5.06, + "Total Cycle Time": 5, + "Product In Stock": "YES", + "PID": 6632, + "Market Segment": "CONSUMER" + }, +{ + "Id": 2, + "Item Count": 1, + "Ship Priority": "0", + "Order Priority": "4-NOT SPECIFIED", + "Order Status": "F", + "Order Quantity": 36, + "Sales Total": 603.9, + "Discount": 0.07, + "Tax Rate": 0.02, + "Ship Mode": "REGULAR AIR", + "Fill Time": 1, + "Gross Profit": 168.93, + "Price": 17.52, + "Ship Handle Cost": 5.6, + "Employee Name": "Purkey, Jan", + "Employee Dept": "1054", + "Manager Name": "Collins, Babs", + "Employee Yrs Exp": 6, + "Employee Salary": 104677, + "Customer Name": "Nathan Mautz", + "Customer State": "ILLINOIS", + "Call Center Region": "CENTRAL", + "Customer Balance": 1820, + "Customer Segment": "HOME OFFICE", + "Prod Type1": "OFFICE SUPPLIES", + "Prod Type2": "PAPER", + "Prod Type3": "WRITINGS PADS", + "Prod Type4": "MEMO SLIPS", + "Product Name": "TOPS Carbonless Receipt Book, Four 2-3/4 x 7-1/4 Money Receipts per Page", + "Product Container": "WRAP BAG", + "Ship Promo": "REGULAR SHIPPING", + "Supplier Name": "Supplier_090", + "Supplier Balance": 6202, + "Supplier Region": "WEST", + "Supplier State": "NEW MEXICO", + "Order ID": "1250", + "Order Year": 1997, + "Order Month": 9, + "Order Day": 29, + "Order Date": "1997-09-29T00:00:00.000", + "Order Quarter": "Q3", + "Product Base Margin": 0.37, + "Product ID": "1860", + "Receive Time": 2, + "Received Date": "1997-10-02T00:00:00.000", + "Ship Date": "1997-09-30T00:00:00.000", + "Ship Charge": 5.6, + "Total Cycle Time": 3, + "Product In Stock": "YES", + "PID": 6981, + "Market Segment": "HOME OFFICE" +} +]); + + diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3334/query-ASTERIXDB-3334.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3334/query-ASTERIXDB-3334.3.query.sqlpp new file mode 100644 index 0000000000..b6104e5c32 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3334/query-ASTERIXDB-3334.3.query.sqlpp @@ -0,0 +1,37 @@ +/* + * 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: This test case is to verify the fix for ASTERIXDB-3316 + */ + +use test; + +SELECT `Staples`.`Employee Name` AS `Employee Name`, + AVG(`Staples`.`Employee Salary`) AS `avg:Employee Salary:ok` +FROM `Staples` `Staples` + INNER JOIN ( + SELECT `Staples`.`Call Center Region` AS `Call Center Region`, + `Staples`.`Employee Name` AS `Employee Name` + FROM `Staples` `Staples` + GROUP BY `Staples`.`Call Center Region`, + `Staples`.`Employee Name` + HAVING ((AVG(`Staples`.`Employee Salary`)>=102499.99999999898) AND (AVG(`Staples`.`Employee Salary`)<=110000.00000000111)) +) `t0` ON ((`Staples`.`Call Center Region` = `t0`.`Call Center Region`) AND (`Staples`.`Employee Name` = `t0`.`Employee Name`)) +GROUP BY `Staples`.`Employee Name` \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3334/query-ASTERIXDB-3334.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3334/query-ASTERIXDB-3334.3.adm new file mode 100644 index 0000000000..e99dc40188 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3334/query-ASTERIXDB-3334.3.adm @@ -0,0 +1 @@ +{ "Employee Name": "Purkey, Jan", "avg:Employee Salary:ok": 104677.0 } 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 7bf9b307a3..a9fbbe3e7a 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml @@ -7285,6 +7285,11 @@ <output-dir compare="Text">serialized_size_fun</output-dir> </compilation-unit> </test-case> + <test-case FilePath="misc"> + <compilation-unit name="query-ASTERIXDB-3334"> + <output-dir compare="Text">query-ASTERIXDB-3334</output-dir> + </compilation-unit> + </test-case> </test-group> <test-group name="multipart-dataverse"> <test-case FilePath="multipart-dataverse"> diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/UnorderedPartitionedProperty.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/UnorderedPartitionedProperty.java index fa8650c370..3d52d01748 100644 --- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/UnorderedPartitionedProperty.java +++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/UnorderedPartitionedProperty.java @@ -72,11 +72,13 @@ public final class UnorderedPartitionedProperty extends AbstractGroupingProperty @Override public IPartitioningProperty substituteColumnVars(Map<LogicalVariable, LogicalVariable> varMap) { boolean applied = false; - Set<LogicalVariable> newColumnSet = new ListSet<>(columnSet); - for (Map.Entry<LogicalVariable, LogicalVariable> me : varMap.entrySet()) { - if (newColumnSet.remove(me.getKey())) { - newColumnSet.add(me.getValue()); + Set<LogicalVariable> newColumnSet = new ListSet<>(); + for (LogicalVariable variable : columnSet) { + if (varMap.containsKey(variable)) { + newColumnSet.add(varMap.get(variable)); applied = true; + } else { + newColumnSet.add(variable); } } return applied ? new UnorderedPartitionedProperty(newColumnSet, domain) : this;
