This is an automated email from the ASF dual-hosted git repository.

mhubail pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git

commit 16ac1d8c0ba5c8131881e2cf8ff1be100905788e
Author: Ali Alsuliman <[email protected]>
AuthorDate: Tue Feb 11 18:18:55 2025 -0800

    [ASTERIXDB-3562][COMP] Align subplan variable propagation with runtime 
output
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    Subplan output tuple is formed by concatenating the input tuple
    to the subplan and the subplan's root operator. The variable propagation
    policy should do the same thing.
    
    Ext-ref: MB-65303
    
    Change-Id: I1c30a8fd7e0ab0a9c1629f749b5955b45b40b4d8
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19410
    Tested-by: Ian Maxon <[email protected]>
    Tested-by: Ali Alsuliman <[email protected]>
    Reviewed-by: Ali Alsuliman <[email protected]>
    Reviewed-by: Michael Blow <[email protected]>
    Integration-Tests: Jenkins <[email protected]>
    (cherry picked from commit ac42a2aae911de860a1d81f7462ed647b656633b)
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19425
    Reviewed-by: Ian Maxon <[email protected]>
---
 .../optimizerts/queries/query-ASTERIXDB-3562.sqlpp | 32 ++++++++++++++++++
 .../optimizerts/results/query-ASTERIXDB-3562.plan  | 38 ++++++++++++++++++++++
 .../query-ASTERIXDB-3562.1.ddl.sqlpp               | 29 +++++++++++++++++
 .../query-ASTERIXDB-3562.2.update.sqlpp            | 22 +++++++++++++
 .../query-ASTERIXDB-3562.3.query.sqlpp             | 22 +++++++++++++
 .../query-ASTERIXDB-3562.5.ddl.sqlpp               | 20 ++++++++++++
 .../query-ASTERIXDB-3562.3.adm                     |  1 +
 .../src/test/resources/runtimets/sqlpp_queries.xml |  5 +++
 .../algebra/operators/logical/SubplanOperator.java |  2 +-
 9 files changed, 170 insertions(+), 1 deletion(-)

diff --git 
a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/query-ASTERIXDB-3562.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/query-ASTERIXDB-3562.sqlpp
new file mode 100644
index 0000000000..61b8a13846
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/query-ASTERIXDB-3562.sqlpp
@@ -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: This test case is to verify the fix for ASTERIXDB-3562
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use test;
+create type dt1 as {id: int};
+create dataset collection1(dt1) PRIMARY KEY id;
+
+// NOTE: this plan is needed to contain 2 consecutive subplan operators since 
that triggers the bug.
+use test;
+SELECT array1[0:1] AS f_1, array1[0:2] AS f_2 FROM collection1;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/optimizerts/results/query-ASTERIXDB-3562.plan
 
b/asterixdb/asterix-app/src/test/resources/optimizerts/results/query-ASTERIXDB-3562.plan
new file mode 100644
index 0000000000..fc97335579
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/optimizerts/results/query-ASTERIXDB-3562.plan
@@ -0,0 +1,38 @@
+distribute result [$$17]
+-- DISTRIBUTE_RESULT  |PARTITIONED|
+  exchange
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    project ([$$17])
+    -- STREAM_PROJECT  |PARTITIONED|
+      assign [$$17] <- [{"f_1": $$14, "f_2": $$16}]
+      -- ASSIGN  |PARTITIONED|
+        project ([$$14, $$16])
+        -- STREAM_PROJECT  |PARTITIONED|
+          subplan {
+                    assign [$$16] <- [array-slice($$19, 0, 2)] [cardinality: 
0.0, op-cost: 0.0, total-cost: 0.0]
+                    -- ASSIGN  |LOCAL|
+                      nested tuple source [cardinality: 0.0, op-cost: 0.0, 
total-cost: 0.0]
+                      -- NESTED_TUPLE_SOURCE  |LOCAL|
+                 }
+          -- SUBPLAN  |PARTITIONED|
+            subplan {
+                      assign [$$14] <- [array-slice($$19, 0, 1)] [cardinality: 
0.0, op-cost: 0.0, total-cost: 0.0]
+                      -- ASSIGN  |LOCAL|
+                        nested tuple source [cardinality: 0.0, op-cost: 0.0, 
total-cost: 0.0]
+                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                   }
+            -- SUBPLAN  |PARTITIONED|
+              project ([$$19])
+              -- STREAM_PROJECT  |PARTITIONED|
+                assign [$$19] <- [$$collection1.getField("array1")]
+                -- ASSIGN  |PARTITIONED|
+                  project ([$$collection1])
+                  -- STREAM_PROJECT  |PARTITIONED|
+                    exchange
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      data-scan []<-[$$18, $$collection1] <- test.collection1
+                      -- DATASOURCE_SCAN  |PARTITIONED|
+                        exchange
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          empty-tuple-source
+                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3562/query-ASTERIXDB-3562.1.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3562/query-ASTERIXDB-3562.1.ddl.sqlpp
new file mode 100644
index 0000000000..37472fc52a
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3562/query-ASTERIXDB-3562.1.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * 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-3562
+ */
+
+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-3562/query-ASTERIXDB-3562.2.update.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3562/query-ASTERIXDB-3562.2.update.sqlpp
new file mode 100644
index 0000000000..147840560b
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3562/query-ASTERIXDB-3562.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;
+
+upsert into collection1 { "id":1, "array1": [1,2,3]};
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3562/query-ASTERIXDB-3562.3.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3562/query-ASTERIXDB-3562.3.query.sqlpp
new file mode 100644
index 0000000000..e64ea19797
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3562/query-ASTERIXDB-3562.3.query.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;
+
+SELECT array1[0:1] AS f_1, array1[0:2] AS f_2 FROM collection1;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3562/query-ASTERIXDB-3562.5.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3562/query-ASTERIXDB-3562.5.ddl.sqlpp
new file mode 100644
index 0000000000..548e63267e
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3562/query-ASTERIXDB-3562.5.ddl.sqlpp
@@ -0,0 +1,20 @@
+/*
+ * 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;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3562/query-ASTERIXDB-3562.3.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3562/query-ASTERIXDB-3562.3.adm
new file mode 100644
index 0000000000..2221625282
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3562/query-ASTERIXDB-3562.3.adm
@@ -0,0 +1 @@
+{ "f_1": [ 1 ], "f_2": [ 1, 2 ] }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml 
b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
index 85ac43b821..8dfc136924 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
@@ -7325,6 +7325,11 @@
         <output-dir compare="Text">remove_listify</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="misc">
+      <compilation-unit name="query-ASTERIXDB-3562">
+        <output-dir compare="Text">query-ASTERIXDB-3562</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/logical/SubplanOperator.java
 
b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SubplanOperator.java
index 72150a90fa..0edd8f7c7e 100644
--- 
a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SubplanOperator.java
+++ 
b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SubplanOperator.java
@@ -70,7 +70,7 @@ public class SubplanOperator extends 
AbstractOperatorWithNestedPlans {
 
     @Override
     public VariablePropagationPolicy getVariablePropagationPolicy() {
-        return VariablePropagationPolicy.ADDNEWVARIABLES;
+        return VariablePropagationPolicy.ALL;
     }
 
     @Override

Reply via email to