You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by al...@apache.org on 2024/09/14 00:26:20 UTC

(asterixdb) 01/14: [ASTERIXDB-3490][COMP] Could not modify UNORDERED_PARTITIONED exception on query compilation

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 5e67b3774887775e9631273552d533aa3013ac9c
Author: Peeyush Gupta <pe...@couchbase.com>
AuthorDate: Tue Aug 27 09:17:23 2024 -0700

    [ASTERIXDB-3490][COMP] Could not modify UNORDERED_PARTITIONED exception on query compilation
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Ext-ref:MB-63207
    Change-Id: I60b615653ff8b41b43796ad37ddf97a5184b03e6
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18764
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Ali Alsuliman <al...@gmail.com>
---
 .../query-ASTERIXDB-3490.1.ddl.sqlpp               |  39 +++++++
 .../query-ASTERIXDB-3490.2.update.sqlpp            | 123 +++++++++++++++++++++
 .../query-ASTERIXDB-3490.3.query.sqlpp             |  48 ++++++++
 .../query-ASTERIXDB-3490.4.query.sqlpp             |  49 ++++++++
 .../query-ASTERIXDB-3490.3.adm                     |   1 +
 .../query-ASTERIXDB-3490.4.adm                     |   1 +
 .../test/resources/runtimets/testsuite_sqlpp.xml   |   5 +
 .../physical/AbstractHashJoinPOperator.java        |   4 +-
 8 files changed, 269 insertions(+), 1 deletion(-)

diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.1.ddl.sqlpp
new file mode 100644
index 0000000000..c24047061e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.1.ddl.sqlpp
@@ -0,0 +1,39 @@
+/*
+ * 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-3490
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
+create type dt1 as {id: int};
+
+create dataset collection1(dt1) PRIMARY KEY id;
+create dataset collection2(dt1) PRIMARY KEY id;
+create dataset collection3(dt1) PRIMARY KEY id;
+create dataset collection4(dt1) PRIMARY KEY id;
+create dataset collection5(dt1) PRIMARY KEY id;
+create dataset collection6(dt1) PRIMARY KEY id;
+
+create dataset dataset0(dt1) PRIMARY KEY id;
+create dataset dataset1(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-3490/query-ASTERIXDB-3490.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.2.update.sqlpp
new file mode 100644
index 0000000000..8b127ab243
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.2.update.sqlpp
@@ -0,0 +1,123 @@
+/*
+ * 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;
+
+upsert into collection1
+[
+    {
+        "id":1,
+        "t1":10,
+        "t2":10,
+        "t":10,
+        "p1":3,
+        "p2":3,
+        "p":3
+    }
+];
+
+upsert into collection2
+[
+    {
+        "id":1,
+        "t1":10,
+        "t2":10,
+        "t":10,
+        "p1":3,
+        "p2":3,
+        "p":3
+    }
+];
+
+upsert into collection3
+[
+    {
+        "id":1,
+        "t1":10,
+        "t2":10,
+        "t":10,
+        "p1":3,
+        "p2":3,
+        "p":3
+    }
+];
+
+upsert into collection4
+[
+    {
+        "id":1,
+        "t1":10,
+        "t2":10,
+        "t":10,
+        "p1":3,
+        "p2":3,
+        "p":3
+    }
+];
+
+upsert into collection5
+[
+    {
+        "id":1,
+        "t1":10,
+        "t2":10,
+        "t":10,
+        "p1":3,
+        "p2":3,
+        "p":3
+    }
+];
+
+upsert into collection6
+[
+    {
+        "id":1,
+        "t1":10,
+        "t2":10,
+        "t":10,
+        "p1":3,
+        "p2":3,
+        "p":3
+    }
+];
+
+
+upsert into dataset0
+    [{
+        "id":10,
+        "a":12,
+        "y_id":10,
+        "b":20,
+        "u": 101,
+        "x_id":10,
+        "p":3
+    }];
+
+upsert into dataset1
+    [{
+        "id":1,
+        "a":12,
+        "y_id":10,
+        "b":20,
+        "u": 101,
+        "x_id":10,
+        "p":3
+    }];
+
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.3.query.sqlpp
new file mode 100644
index 0000000000..f319efc300
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.3.query.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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-3490
+ */
+
+use test;
+
+SELECT value a1
+FROM collection1 a1
+WHERE (
+    SELECT  value count(*)
+    FROM collection2 a2
+    WHERE a1.t=a2.t and a1.p=3 and (
+       SELECT value count(*)
+        FROM collection3 a3
+        WHERE a2.t1=a3.t1 and a2.p1=3 and (
+            SELECT value count(*)
+                FROM collection4 a4
+                WHERE a3.t2=a4.t2 and a3.p2=3 and (
+                    SELECT value count(*)
+                        FROM collection5 a5
+                        WHERE a4.t=a5.t and a4.p=3 and (
+                        SELECT value count(*)
+                            FROM collection6 a6
+                            WHERE a5.t1=a6.t1 and a5.p1=3
+                        )[0] >= 1
+                    )[0] >= 1
+                )[0] >= 1
+        )[0] >= 1
+    )[0] >= 1;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.4.query.sqlpp
new file mode 100644
index 0000000000..2313a6d064
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.4.query.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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-3490
+ */
+
+use test;
+
+SET `rewrite_or_as_join` "false";
+SELECT DISTINCT T1.*,
+                (SELECT VALUE H.u
+                  FROM dataset1 H
+                  WHERE H.y_id = to_string(T1.x_id)
+                    AND H.a IN [12, 66, 67, 13, 26]
+                    AND H.b IN
+                        (SELECT value MAX(L.b)
+                           FROM dataset1 L
+                          WHERE L.y_id = T1.x_id
+                            AND L.a IN [12, 66, 67, 13, 26]
+                            )
+                            LIMIT 1
+                )[0] AS sub_q1,
+                b_max
+FROM (SELECT ROW_NUMBER() OVER(ORDER BY sub_q2.b_max DESC NULLS LAST) AS ROW_NUMBER,
+             T0.x_id,
+             sub_q2.b_max
+      FROM dataset0 T0 INNER JOIN
+      (SELECT y_id, MAX(b) b_max
+       FROM dataset1 T2
+       GROUP BY y_id) AS sub_q2
+      ON sub_q2.y_id = T0.id
+) T1;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.3.adm
new file mode 100644
index 0000000000..22c03b0446
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.3.adm
@@ -0,0 +1 @@
+{ "id": 1, "t1": 10, "t2": 10, "t": 10, "p1": 3, "p2": 3, "p": 3 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.4.adm
new file mode 100644
index 0000000000..a617f178c1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3490/query-ASTERIXDB-3490.4.adm
@@ -0,0 +1 @@
+{ "b_max": 20, "ROW_NUMBER": 1, "x_id": 10 }
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 58407871eb..3e4b09ef52 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -7305,6 +7305,11 @@
         <output-dir compare="Text">query-ASTERIXDB-3403</output-dir>
       </compilation-unit>
     </test-case>
+      <test-case FilePath="misc">
+        <compilation-unit name="query-ASTERIXDB-3490">
+          <output-dir compare="Text">query-ASTERIXDB-3490</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/operators/physical/AbstractHashJoinPOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/AbstractHashJoinPOperator.java
index 38ccee5925..c9f59c6281 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/AbstractHashJoinPOperator.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/AbstractHashJoinPOperator.java
@@ -168,7 +168,9 @@ public abstract class AbstractHashJoinPOperator extends AbstractJoinPOperator {
                                         EquivalenceClass ecFst = eqmap.get(v2);
                                         for (LogicalVariable vset1 : set1) {
                                             if (vset1 == v2 || ecFst != null && eqmap.get(vset1) == ecFst) {
-                                                covered.add(vset1);
+                                                if (!covered.add(vset1)) {
+                                                    continue;
+                                                }
                                                 modifuppreq.add(r);
                                                 break;
                                             }