[ASTERIXDB-2452] Recompute type env after ListifyUnnestingFunctionRule

- user model changes: no
- storage format changes: no
- interface changes: no

Details:

-Recompute type env of the parent operator after firing
ListifyUnnestingFunctionRule. Otherwise the type env of the parent operator
would still point to the old operator, which is not correct.

Change-Id: I97bf721cb7fc9f36ec14214677d5545ae4aa1d2a
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2967
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ListifyUnnestingFunctionRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ListifyUnnestingFunctionRule.java
index 7f23775..d865ba9 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ListifyUnnestingFunctionRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ListifyUnnestingFunctionRule.java
@@ -156,6 +156,7 @@
         context.computeAndSetTypeEnvironmentForOperator(unnestOperator);
         context.computeAndSetTypeEnvironmentForOperator(aggregateOperator);
         context.computeAndSetTypeEnvironmentForOperator(subplanOperator);
+        context.computeAndSetTypeEnvironmentForOperator(op);
         return true;
     }
 
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/query-ASTERIXDB-2452.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/query-ASTERIXDB-2452.aql
new file mode 100644
index 0000000..f5eb928
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/query-ASTERIXDB-2452.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.
+ */
+
+set import-private-functions 'true'
+
+let $nullstring := [null, null, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+
+let $prefix1 := subset-collection($nullstring, 0, prefix-len-jaccard(len($nullstring), 0.1f))
+let $prefix4 := subset-collection($nullstring, 0, prefix-len-jaccard(len($nullstring), 0.4f))
+
+let $joinpair :=
+  for $s in $prefix4
+  for $r in $prefix1
+  where $s = $r
+  return $s
+
+return [$joinpair]
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/query-ASTERIXDB-2452.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/query-ASTERIXDB-2452.plan
new file mode 100644
index 0000000..8ae7027
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/query-ASTERIXDB-2452.plan
@@ -0,0 +1,27 @@
+-- DISTRIBUTE_RESULT  |UNPARTITIONED|
+  -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+    -- STREAM_PROJECT  |UNPARTITIONED|
+      -- ASSIGN  |UNPARTITIONED|
+        -- AGGREGATE  |UNPARTITIONED|
+          -- STREAM_PROJECT  |UNPARTITIONED|
+            -- STREAM_SELECT  |UNPARTITIONED|
+              -- STREAM_PROJECT  |UNPARTITIONED|
+                -- UNNEST  |UNPARTITIONED|
+                  -- STREAM_PROJECT  |UNPARTITIONED|
+                    -- UNNEST  |UNPARTITIONED|
+                      -- STREAM_PROJECT  |UNPARTITIONED|
+                        -- SUBPLAN  |UNPARTITIONED|
+                                {
+                                  -- AGGREGATE  |UNPARTITIONED|
+                                    -- UNNEST  |UNPARTITIONED|
+                                      -- NESTED_TUPLE_SOURCE  |UNPARTITIONED|
+                                }
+                          -- SUBPLAN  |UNPARTITIONED|
+                                  {
+                                    -- AGGREGATE  |UNPARTITIONED|
+                                      -- UNNEST  |UNPARTITIONED|
+                                        -- NESTED_TUPLE_SOURCE  |UNPARTITIONED|
+                                  }
+                            -- ASSIGN  |UNPARTITIONED|
+                              -- ASSIGN  |UNPARTITIONED|
+                                -- EMPTY_TUPLE_SOURCE  |UNPARTITIONED|