Merge commit 'bd728afe' from stabilization-f69489

Change-Id: Ic382adcb9e6f0a084a029206a0785d979a45faad
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/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java
index ae13e42..1301c01 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java
@@ -125,6 +125,7 @@
         }
         ccApplication.registerConfig(configManager);
         final CCConfig ccConfig = createCCConfig(configManager);
+        configManager.processConfig();
         cc = new ClusterControllerService(ccConfig, ccApplication);
 
         nodeNames = ccConfig.getConfigManager().getNodeNames();
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|
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/redundant-var-in-groupby/redundant-var-in-groupby.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/redundant-var-in-groupby/redundant-var-in-groupby.1.ddl.sqlpp
new file mode 100644
index 0000000..3100af6
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/redundant-var-in-groupby/redundant-var-in-groupby.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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 TweetType as open {
+  id : int64
+};
+
+create dataset Tweets(TweetType) primary key id;
+
+drop type NearbyBuildingType if exists;
+create type NearbyBuildingType as open {
+    buildingId: int64,
+    buildingType : string,
+    buildingLocation : point
+};
+create dataset NearbyBuildings(NearbyBuildingType) primary key buildingId;
+
+create function annotateTweet(x) {
+    LET nearby_buildings = (select r.buildingType as buildingType, count(r) as cnt
+       from NearbyBuildings r
+       where spatial_intersect(create_point(x.latitude, x.longitude), create_circle(r.buildingLocation, 3.0))
+       group by r.buildingType)
+    select x.*, nearby_buildings
+};
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/redundant-var-in-groupby/redundant-var-in-groupby.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/redundant-var-in-groupby/redundant-var-in-groupby.2.update.sqlpp
new file mode 100644
index 0000000..ab13484
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/redundant-var-in-groupby/redundant-var-in-groupby.2.update.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * 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 Tweets([{"id": 1, "text" : "im tweet", "latitude":0.0, "longitude" : 0.0}]);
+
+insert into NearbyBuildings([{"buildingId" : 0, "buildingType" : "school", "buildingLocation" : point("1, 1")},
+{"buildingId" : 1, "buildingType" : "school", "buildingLocation" : point("-1, 1")},
+{"buildingId" : 2, "buildingType" : "hospital", "buildingLocation" : point("1, -1")}]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/redundant-var-in-groupby/redundant-var-in-groupby.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/redundant-var-in-groupby/redundant-var-in-groupby.3.query.sqlpp
new file mode 100644
index 0000000..55a1c37
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/redundant-var-in-groupby/redundant-var-in-groupby.3.query.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.
+ */
+ use test;
+select value annotateTweet(t) from Tweets t;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/redundant-var-in-groupby/redundant-var-in-groupby.4.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/redundant-var-in-groupby/redundant-var-in-groupby.4.ddl.sqlpp
new file mode 100644
index 0000000..d4b1d9d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/redundant-var-in-groupby/redundant-var-in-groupby.4.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/coalesce/coalesce.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/coalesce/coalesce.1.query.sqlpp
new file mode 100644
index 0000000..18a73e3
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/coalesce/coalesce.1.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+/* coalesce() is equivalent to ifmissingornull() */
+
+{
+   "a": isnull(coalesce()),
+   "b": isnull(coalesce(missing)),
+   "c": isnull(coalesce(null)),
+   "d": isnull(coalesce(null, missing)),
+   "e": coalesce(null, true, 1),
+   "f": coalesce(missing, true, 1),
+   "g": coalesce(null, missing, true, 1),
+   "h": coalesce(null, missing, true, 1),
+   "i": coalesce(
+            missing,
+            null,
+            case when get_year(current_datetime()) > 0 then missing else false end,
+            case when get_year(current_datetime()) > 0 then null else false end,
+            case when get_year(current_datetime()) > 0 then true else missing end
+        )
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/group-by/redundant-var-in-groupby/redundant-var-in-groupby.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/group-by/redundant-var-in-groupby/redundant-var-in-groupby.1.adm
new file mode 100644
index 0000000..c563f9c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/group-by/redundant-var-in-groupby/redundant-var-in-groupby.1.adm
@@ -0,0 +1 @@
+[ { "nearby_buildings": [ { "buildingType": "hospital", "cnt": 1 }, { "buildingType": "school", "cnt": 2 } ], "id": 1, "text": "im tweet", "latitude": 0.0, "longitude": 0.0 } ]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/coalesce/coalesce.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/coalesce/coalesce.1.adm
new file mode 100644
index 0000000..633c503
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/coalesce/coalesce.1.adm
@@ -0,0 +1 @@
+{ "a": true, "b": true, "c": true, "d": true, "e": true, "f": true, "g": true, "h": true, "i": true }
\ 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 0127896..9bb995e 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -3232,6 +3232,11 @@
         <expected-error>The byte size of a single group</expected-error>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="group-by">
+      <compilation-unit name="redundant-var-in-groupby">
+        <output-dir compare="Text">redundant-var-in-groupby</output-dir>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="index-join">
     <test-case FilePath="index-join">
@@ -4958,6 +4963,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="null-missing">
+      <compilation-unit name="coalesce">
+        <output-dir compare="Text">coalesce</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="null-missing">
       <compilation-unit name="query-ASTERIXDB-1689">
         <output-dir compare="Text">query-ASTERIXDB-1689</output-dir>
       </compilation-unit>
diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/13_conditional.md b/asterixdb/asterix-doc/src/main/markdown/builtins/13_conditional.md
index f0e98fd..8c2dce7 100644
--- a/asterixdb/asterix-doc/src/main/markdown/builtins/13_conditional.md
+++ b/asterixdb/asterix-doc/src/main/markdown/builtins/13_conditional.md
@@ -75,7 +75,7 @@
 
  The function has an alias `ifmissing`.
 
-### if_missing_or_null (ifmissingornull) ###
+### if_missing_or_null (ifmissingornull, coalesce) ###
 
  * Syntax:
 
@@ -100,7 +100,7 @@
 
         { "a": null, "b": null, "c": "asterixdb" }
 
- The function has an alias `ifmissingornull`.
+ The function has two aliases: `ifmissingornull` and `coalesce`.
 
 ### if_inf (ifinf) ###
 
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/jackson/ObjectPool.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/jackson/ObjectPool.java
index 5ccd9e9..8945e71 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/jackson/ObjectPool.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/jackson/ObjectPool.java
@@ -59,4 +59,9 @@
             recycledObjects.add(object);
         }
     }
+
+    @Override
+    public String toString() {
+        return recycledObjects.toString();
+    }
 }
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
index 372acab..631bb7b 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
@@ -73,6 +73,7 @@
         addFunctionMapping("ifinf", "if-inf"); // ifinf, internal: if-inf
         addFunctionMapping("ifnan", "if-nan"); // ifnan, internal: if-nan
         addFunctionMapping("ifnanorinf", "if-nan-or-inf"); // ifnanorinf, internal: if-nan-or-inf
+        addFunctionMapping("coalesce", "if-missing-or-null"); // coalesce, internal: if-missing-or-null
         addFunctionMapping("missingif", "missing-if"); // missingif, internal: missing-if
         addFunctionMapping("nanif", "nan-if"); // nanif, internal: nan-if
         addFunctionMapping("neginfif", "neginf-if"); // neginfif, internal: neginf-if
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/SerializerDeserializerProvider.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/SerializerDeserializerProvider.java
index 0cba8b6..356b84c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/SerializerDeserializerProvider.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/SerializerDeserializerProvider.java
@@ -171,7 +171,7 @@
     }
 
     @SuppressWarnings("rawtypes")
-    private ISerializerDeserializer addTag(final ISerializerDeserializer nonTaggedSerde) {
+    public static ISerializerDeserializer addTag(final ISerializerDeserializer nonTaggedSerde) {
         return new ISerializerDeserializer<IAObject>() {
 
             private static final long serialVersionUID = 1L;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AbstractVisitablePointable.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AbstractVisitablePointable.java
index 2ff9357..e9aa99c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AbstractVisitablePointable.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AbstractVisitablePointable.java
@@ -59,4 +59,10 @@
         set(ivf.getByteArray(), ivf.getStartOffset(), ivf.getLength());
     }
 
+    @Override
+    public String toString() {
+        return "{ \"class\" : \"" + getClass().getSimpleName() + "\", \"data\" : "
+                + (data == null ? "null" : ("\"" + System.identityHashCode(data) + ":" + data.length + "\""))
+                + ", \"offset\" : " + start + ", \"length\" : " + len + " }";
+    }
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/PointableAllocator.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/PointableAllocator.java
index 91c47fd..411f067 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/PointableAllocator.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/PointableAllocator.java
@@ -58,7 +58,7 @@
                 }
             });
 
-    public IVisitablePointable allocateEmpty() {
+    public AFlatValuePointable allocateEmpty() {
         return flatValueAllocator.allocate(null);
     }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeComputeUtils.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeComputeUtils.java
index 806235c..f1f1be3 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeComputeUtils.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeComputeUtils.java
@@ -168,7 +168,7 @@
         }
         IAType resultType = type;
         if ((category & NULLABLE) != 0 || (category & NULL) != 0) {
-            resultType = AUnionType.createUnknownableType(resultType);
+            resultType = AUnionType.createNullableType(resultType);
         }
         if ((category & MISSABLE) != 0 || (category & MISSING) != 0) {
             resultType = AUnionType.createMissableType(resultType);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/utils/AdmNodeUtils.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/utils/AdmNodeUtils.java
index 6f4ee17..f8ce905 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/utils/AdmNodeUtils.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/utils/AdmNodeUtils.java
@@ -36,6 +36,7 @@
 import org.apache.asterix.om.types.AOrderedListType;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.ATypeTag;
+import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.BooleanPointable;
 import org.apache.hyracks.data.std.primitive.DoublePointable;
 import org.apache.hyracks.data.std.primitive.LongPointable;
@@ -56,6 +57,45 @@
         return map;
     }
 
+    public static IAdmNode getAsAdmNode(IPointable pointable) throws IOException {
+        byte[] bytes = pointable.getByteArray();
+        int offset = pointable.getStartOffset();
+        int len = pointable.getLength();
+        if (len == 0) {
+            throw new IllegalArgumentException();
+        }
+        byte tagByte = bytes[offset];
+        ATypeTag tag = ATypeTag.VALUE_TYPE_MAPPING[tagByte];
+        switch (tag) {
+            case ARRAY:
+                AListPointable listPointable = AListPointable.FACTORY.createPointable();
+                listPointable.set(bytes, offset, len);
+                return getAsAdmNode(listPointable);
+            case BIGINT:
+                return new AdmBigIntNode(LongPointable.getLong(bytes, offset + 1));
+            case BOOLEAN:
+                return AdmBooleanNode.get(BooleanPointable.getBoolean(bytes, offset + 1));
+            case DOUBLE:
+                return new AdmDoubleNode(DoublePointable.getDouble(bytes, offset + 1));
+            case NULL:
+                return AdmNullNode.INSTANCE;
+            case OBJECT:
+                ARecordPointable recPointable = ARecordPointable.FACTORY.createPointable();
+                recPointable.set(bytes, offset, len);
+                try {
+                    return new AdmObjectNode(getOpenFields(recPointable, RecordUtil.FULLY_OPEN_RECORD_TYPE));
+                } catch (IOException e) {
+                    throw new IllegalArgumentException(e);
+                }
+            case STRING:
+                UTF8StringPointable str = UTF8StringPointable.FACTORY.createPointable();
+                str.set(bytes, offset + 1, len - 1);
+                return new AdmStringNode(str.toString());
+            default:
+                throw new UnsupportedOperationException("Unsupported item type: " + tag);
+        }
+    }
+
     private static IAdmNode getOpenField(ARecordPointable recPointable, ARecordType type, int i) throws IOException {
         byte tagByte = recPointable.getOpenFieldTag(type, i);
         ATypeTag tag = ATypeTag.VALUE_TYPE_MAPPING[tagByte];
diff --git a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/AbstractIntroduceGroupByCombinerRule.java b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/AbstractIntroduceGroupByCombinerRule.java
index dc48d96..7b9c255 100644
--- a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/AbstractIntroduceGroupByCombinerRule.java
+++ b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/AbstractIntroduceGroupByCombinerRule.java
@@ -84,10 +84,12 @@
             // p.second.getValue() should always return a VariableReferenceExpression, hence
             // usedDecorVars should always contain only one variable.
             p.second.getValue().getUsedVariables(usedDecorVars);
-            if (!newGbyLiveVars.contains(usedDecorVars.get(0))) {
+            LogicalVariable usedVar = usedDecorVars.get(0);
+            if (!newGbyLiveVars.contains(usedVar)) {
                 // Let the left-hand side of gbyOp's decoration expressions populated through the combiner group-by without
                 // any intermediate assignment.
                 newGbyOp.addDecorExpression(null, p.second.getValue());
+                newGbyLiveVars.add(usedVar);
             }
         }
         newGbyOp.setExecutionMode(ExecutionMode.LOCAL);
@@ -97,14 +99,11 @@
         Object v2 = gbyOp.getAnnotations().get(OperatorAnnotations.USE_EXTERNAL_GROUP_BY);
         newGbyOp.getAnnotations().put(OperatorAnnotations.USE_EXTERNAL_GROUP_BY, v2);
 
-        List<LogicalVariable> propagatedVars = new LinkedList<LogicalVariable>();
-        VariableUtilities.getProducedVariables(newGbyOp, propagatedVars);
-
         Set<LogicalVariable> freeVars = new HashSet<LogicalVariable>();
         OperatorPropertiesUtil.getFreeVariablesInSubplans(gbyOp, freeVars);
 
         for (LogicalVariable var : freeVars) {
-            if (!propagatedVars.contains(var)) {
+            if (!newGbyLiveVars.contains(var)) {
                 LogicalVariable newDecorVar = context.newVar();
                 VariableReferenceExpression varRef = new VariableReferenceExpression(var);
                 varRef.setSourceLocation(gbyOp.getSourceLocation());
@@ -435,8 +434,8 @@
      *            The optimization context.
      * @param nestedGby
      *            The nested gby operator in the global gby operator's subplan.
-     * @param firstAggVar
-     *            The first aggregation variable produced by the combiner gby.
+     * @param aggregateVarsProducedByCombiner
+     *            The aggregation variables produced by the combiner gby.
      */
     protected abstract void processNullTest(IOptimizationContext context, GroupByOperator nestedGby,
             List<LogicalVariable> aggregateVarsProducedByCombiner);
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCDriver.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCDriver.java
index c4ad139..8b58046 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCDriver.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCDriver.java
@@ -53,6 +53,7 @@
             CCLogConfigurationFactory logCfgFactory = new CCLogConfigurationFactory(ccConfig);
             ConfigurationFactory.setConfigurationFactory(logCfgFactory);
             cfg.removeLogger("Console");
+            configManager.processConfig();
             ctx.start(logCfgFactory.getConfiguration(ctx, ConfigurationSource.NULL_SOURCE));
             ClusterControllerService ccService = new ClusterControllerService(ccConfig, application);
             ccService.start();
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/ClusterControllerService.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/ClusterControllerService.java
index b5dacfb..b2e4a5e 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/ClusterControllerService.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/ClusterControllerService.java
@@ -161,7 +161,6 @@
             throw new IllegalArgumentException("ICCApplication cannot be null");
         }
         this.application = application;
-        configManager.processConfig();
         File jobLogFolder = new File(ccConfig.getRootDir(), "logs/jobs");
         jobLog = new LogFile(jobLogFolder);
 
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NCDriver.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NCDriver.java
index fdd271c..b460735 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NCDriver.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NCDriver.java
@@ -52,6 +52,7 @@
             Configuration cfg = ctx.getConfiguration();
             NCLogConfigurationFactory logCfgFactory = new NCLogConfigurationFactory(ncConfig);
             ConfigurationFactory.setConfigurationFactory(logCfgFactory);
+            configManager.processConfig();
             cfg.removeLogger("Console");
             ctx.start(logCfgFactory.getConfiguration(ctx, ConfigurationSource.NULL_SOURCE));
             final NodeControllerService ncService = new NodeControllerService(ncConfig, application);
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NodeControllerService.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NodeControllerService.java
index 653d6e01..d7da5a4 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NodeControllerService.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NodeControllerService.java
@@ -193,7 +193,6 @@
         if (application == null) {
             throw new IllegalArgumentException("INCApplication cannot be null");
         }
-        configManager.processConfig();
         this.application = application;
         id = ncConfig.getNodeId();
         if (id == null) {