This is an automated email from the ASF dual-hosted git repository. alsuliman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 34b917c43c097e34c98b99637141aec714393f6f Author: Peeyush Gupta <[email protected]> AuthorDate: Tue May 21 11:58:43 2024 -0700 [ASTERIXDB-3403][COMP] Compilation error with valid query - user model changes: no - storage format changes: no - interface changes: no Change-Id: I0a2ee2923860a5fe215206eea45421f00b615f40 Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18305 Reviewed-by: Ali Alsuliman <[email protected]> Tested-by: Peeyush Gupta <[email protected]> --- .../rules/CancelUnnestWithNestedListifyRule.java | 2 +- .../rules/RemoveRedundantListifyRule.java | 2 +- .../query-ASTERIXDB-3403.1.ddl.sqlpp | 30 ++++++++++++++ .../query-ASTERIXDB-3403.2.update.sqlpp | 47 ++++++++++++++++++++++ .../query-ASTERIXDB-3403.3.query.sqlpp | 40 ++++++++++++++++++ .../query-ASTERIXDB-3403.3.adm | 1 + .../test/resources/runtimets/testsuite_sqlpp.xml | 5 +++ 7 files changed, 125 insertions(+), 2 deletions(-) diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/CancelUnnestWithNestedListifyRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/CancelUnnestWithNestedListifyRule.java index 069ba49b90..bcb59b4cf1 100644 --- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/CancelUnnestWithNestedListifyRule.java +++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/CancelUnnestWithNestedListifyRule.java @@ -194,7 +194,7 @@ public class CancelUnnestWithNestedListifyRule implements IAlgebraicRewriteRule AggregateOperator agg = (AggregateOperator) nestedPlanRoot; Mutable<ILogicalOperator> aggInputOpRef = agg.getInputs().get(0); - if (agg.getVariables().size() > 1) { + if (agg.getVariables().size() != 1) { return false; } diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/RemoveRedundantListifyRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/RemoveRedundantListifyRule.java index f968b353b4..0f490be1df 100644 --- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/RemoveRedundantListifyRule.java +++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/RemoveRedundantListifyRule.java @@ -200,7 +200,7 @@ public class RemoveRedundantListifyRule implements IAlgebraicRewriteRule { return false; } AggregateOperator agg = (AggregateOperator) r; - if (agg.getVariables().size() > 1) { + if (agg.getVariables().size() != 1) { return false; } LogicalVariable aggVar = agg.getVariables().get(0); diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3403/query-ASTERIXDB-3403.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3403/query-ASTERIXDB-3403.1.ddl.sqlpp new file mode 100644 index 0000000000..0b94eb1499 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3403/query-ASTERIXDB-3403.1.ddl.sqlpp @@ -0,0 +1,30 @@ +/* + * 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-3403 + */ + +drop dataverse test if exists; +create dataverse test; + +use test; + +create type dt1 as {id:int}; +create dataset collection1(dt1) primary key id; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3403/query-ASTERIXDB-3403.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3403/query-ASTERIXDB-3403.2.update.sqlpp new file mode 100644 index 0000000000..327d1d662f --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3403/query-ASTERIXDB-3403.2.update.sqlpp @@ -0,0 +1,47 @@ +/* + * 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 collection1 +([ + { + "id": 1, + "f1": "f1", + "x1": [{"date":"01-02-2024", "item": '1234', "cnt":2}] + + }, + { + "id": 2, + "f1": "f1", + "x2": [{"date":"01-02-2024", "item": '5678', "cnt":2}] + }, + { + "id": 3, + "f1": "f1", + "x3": [{"su": {"x4":2}, "item": "i1", "cnt":2}] + }, + { + "id": 4, + "f1": "f1", + "x3": [{"su": {"x4":5}, "item": 1234, "cnt":2}] + } +]); + + diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3403/query-ASTERIXDB-3403.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3403/query-ASTERIXDB-3403.3.query.sqlpp new file mode 100644 index 0000000000..ca700345e7 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3403/query-ASTERIXDB-3403.3.query.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: This test case is to verify the fix for ASTERIXDB-3403 + */ + +use test; + + SELECT COUNT(id) AS matches + FROM collection1 AS d + WHERE d.`f1` = 'f1' + AND (ARRAY_SUM(( + SELECT VALUE i.`cnt` + FROM d.`x1` AS i + WHERE i.`date` BETWEEN "01-01-2024" AND "02-02-2024" + AND i.`item` IN ['1234', '5678'] )) >= 1 + OR ARRAY_SUM(( + SELECT VALUE i.`cnt` + FROM d.`x2` AS i + WHERE i.`date` BETWEEN "01-01-2024" AND "02-02-2024" + AND i.`item` IN ['1234', '5678'] )) >= 1 + OR (ANY e IN d.x3 SATISFIES e.item IN ['i1', 'i2', 'i3'] + AND e.su.`x4` >= 1 END)); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3403/query-ASTERIXDB-3403.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3403/query-ASTERIXDB-3403.3.adm new file mode 100644 index 0000000000..433b8eed94 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3403/query-ASTERIXDB-3403.3.adm @@ -0,0 +1 @@ +{ "matches": 3 } \ 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 6abac01268..50794f2618 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml @@ -7295,6 +7295,11 @@ <output-dir compare="Text">query-ASTERIXDB-3334</output-dir> </compilation-unit> </test-case> + <test-case FilePath="misc"> + <compilation-unit name="query-ASTERIXDB-3403"> + <output-dir compare="Text">query-ASTERIXDB-3403</output-dir> + </compilation-unit> + </test-case> </test-group> <test-group name="multipart-dataverse"> <test-case FilePath="multipart-dataverse">
