diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/sugar-02/sugar-02.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/sugar-02/sugar-02.4.query.sqlpp
new file mode 100644
index 0000000..c86cd18
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/sugar-02/sugar-02.4.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+/* This query tests the column alias rewriting. */
+
+USE gby;
+
+FROM Employee e
+    JOIN Incentive i ON e.job_category = i.job_category
+    JOIN SuperStars s ON e.id = s.id
+GROUP BY deptId
+HAVING deptId = 'K55'
+SELECT e.department_id AS deptId, coll_sum(e.salary + i.bonus) AS star_cost
+ORDER BY deptId;
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/group-by/core-02/core-02.2.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/group-by/core-02/core-02.2.adm
new file mode 100644
index 0000000..4281a7b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/group-by/core-02/core-02.2.adm
@@ -0,0 +1 @@
+{ "deptId": "K55", "star_cost": 3000 }
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/InlineColumnAliasVisitor.java b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/InlineColumnAliasVisitor.java
index bb8c149..f5f2fe5 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/InlineColumnAliasVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/InlineColumnAliasVisitor.java
@@ -82,22 +82,22 @@
     }
 
     @Override
-    public Void visit(WhereClause whereClause, Boolean arg) throws AsterixException {
-        whereClause.getWhereExpr().accept(this, arg);
+    public Void visit(WhereClause whereClause, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
+        whereClause.getWhereExpr().accept(this, overwriteWithGbyKeyVarRefs);
         return null;
     }
 
     @Override
-    public Void visit(FromClause fromClause, Boolean arg) throws AsterixException {
+    public Void visit(FromClause fromClause, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         for (FromTerm fromTerm : fromClause.getFromTerms()) {
-            fromTerm.accept(this, arg);
+            fromTerm.accept(this, overwriteWithGbyKeyVarRefs);
         }
         return null;
     }
 
     @Override
-    public Void visit(FromTerm fromTerm, Boolean arg) throws AsterixException {
-        fromTerm.getLeftExpression().accept(this, arg);
+    public Void visit(FromTerm fromTerm, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
+        fromTerm.getLeftExpression().accept(this, overwriteWithGbyKeyVarRefs);
         // A from binding variable will override the alias to substitute.
         scopeChecker.getCurrentScope().removeSymbolExpressionMapping(fromTerm.getLeftVariable());
         if (fromTerm.hasPositionalVariable()) {
@@ -105,67 +105,68 @@
         }
 
         for (AbstractBinaryCorrelateClause correlate : fromTerm.getCorrelateClauses()) {
-            correlate.accept(this, arg);
+            correlate.accept(this, overwriteWithGbyKeyVarRefs);
         }
         return null;
     }
 
     @Override
-    public Void visit(JoinClause joinClause, Boolean arg) throws AsterixException {
-        joinClause.getRightExpression().accept(this, arg);
+    public Void visit(JoinClause joinClause, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
+        joinClause.getRightExpression().accept(this, overwriteWithGbyKeyVarRefs);
         removeSubsutitions(joinClause);
-        joinClause.getConditionExpression().accept(this, arg);
+        joinClause.getConditionExpression().accept(this, overwriteWithGbyKeyVarRefs);
         return null;
     }
 
     @Override
-    public Void visit(NestClause nestClause, Boolean arg) throws AsterixException {
-        nestClause.getRightExpression().accept(this, arg);
-        nestClause.getConditionExpression().accept(this, arg);
+    public Void visit(NestClause nestClause, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
+        nestClause.getRightExpression().accept(this, overwriteWithGbyKeyVarRefs);
+        nestClause.getConditionExpression().accept(this, overwriteWithGbyKeyVarRefs);
         removeSubsutitions(nestClause);
         return null;
     }
 
     @Override
-    public Void visit(UnnestClause unnestClause, Boolean arg) throws AsterixException {
-        unnestClause.getRightExpression().accept(this, arg);
+    public Void visit(UnnestClause unnestClause, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
+        unnestClause.getRightExpression().accept(this, overwriteWithGbyKeyVarRefs);
         removeSubsutitions(unnestClause);
         return null;
     }
 
     @Override
-    public Void visit(Projection projection, Boolean arg) throws AsterixException {
-        projection.getExpression().accept(this, arg);
+    public Void visit(Projection projection, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
+        projection.getExpression().accept(this, overwriteWithGbyKeyVarRefs);
         VariableExpr columnAlias = new VariableExpr(
                 SqlppVariableUtil.toInternalVariableIdentifier(projection.getName()));
         VariableSubstitutionEnvironment env = scopeChecker.getCurrentScope().getVarSubstitutionEnvironment();
         Expression gbyKey = (Expression) SqlppRewriteUtil.deepCopy(env.findSubstituion(columnAlias));
-        if (arg) {
-            scopeChecker.getCurrentScope().addSymbolExpressionMappingToScope(columnAlias, projection.getExpression());
-        } else {
+        if (overwriteWithGbyKeyVarRefs) {
             if (gbyKey != null) {
                 projection.setExpression(gbyKey);
             }
+        } else {
+            scopeChecker.getCurrentScope().addSymbolExpressionMappingToScope(columnAlias, projection.getExpression());
         }
         return null;
     }
 
     @Override
-    public Void visit(SelectBlock selectBlock, Boolean arg) throws AsterixException {
+    public Void visit(SelectBlock selectBlock, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         // Traverses the select block in the order of "select", "group-by",
         // "group-by" lets and "having".
-        selectBlock.getSelectClause().accept(this, true);
+        // The first pass over the select clause will not overwrite projection expressions.
+        selectBlock.getSelectClause().accept(this, false);
 
         if (selectBlock.hasFromClause()) {
-            selectBlock.getFromClause().accept(this, arg);
+            selectBlock.getFromClause().accept(this, overwriteWithGbyKeyVarRefs);
         }
         if (selectBlock.hasLetClauses()) {
             for (LetClause letClause : selectBlock.getLetList()) {
-                letClause.accept(this, arg);
+                letClause.accept(this, overwriteWithGbyKeyVarRefs);
             }
         }
         if (selectBlock.hasGroupbyClause()) {
-            selectBlock.getGroupbyClause().accept(this, arg);
+            selectBlock.getGroupbyClause().accept(this, overwriteWithGbyKeyVarRefs);
         }
         if (selectBlock.hasLetClausesAfterGroupby()) {
             for (LetClause letClauseAfterGby : selectBlock.getLetListAfterGroupby()) {
@@ -173,75 +174,119 @@
             }
         }
         if (selectBlock.hasHavingClause()) {
-            selectBlock.getHavingClause().accept(this, arg);
+            selectBlock.getHavingClause().accept(this, overwriteWithGbyKeyVarRefs);
         }
 
-        // Visit select clause again to overwrite projection expressions if the group-by clause is rewritten.
-        selectBlock.getSelectClause().accept(this, false);
+        // Visit select clause again to overwrite projection expressions to group-by
+        // key variable references if any group-by key is the original projection
+        // column alias.
+        selectBlock.getSelectClause().accept(this, true);
         return null;
     }
 
     @Override
-    public Void visit(SelectClause selectClause, Boolean arg) throws AsterixException {
+    public Void visit(SelectClause selectClause, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         if (selectClause.selectElement()) {
-            selectClause.getSelectElement().accept(this, arg);
+            selectClause.getSelectElement().accept(this, overwriteWithGbyKeyVarRefs);
         }
         if (selectClause.selectRegular()) {
-            selectClause.getSelectRegular().accept(this, arg);
+            selectClause.getSelectRegular().accept(this, overwriteWithGbyKeyVarRefs);
         }
         return null;
     }
 
     @Override
-    public Void visit(SelectElement selectElement, Boolean arg) throws AsterixException {
+    public Void visit(SelectElement selectElement, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         Expression expr = selectElement.getExpression();
-        expr.accept(this, arg);
+        expr.accept(this, overwriteWithGbyKeyVarRefs);
         if (expr.getKind() == Kind.RECORD_CONSTRUCTOR_EXPRESSION) {
-            // To be consistent with SelectRegular.
-            mapForRecordConstructor(arg, (RecordConstructor) expr);
+            // Rewrite top-level field names (aliases), in order to be consistent with SelectRegular.
+            mapForRecordConstructor(overwriteWithGbyKeyVarRefs, (RecordConstructor) expr);
         }
         return null;
     }
 
+    /**
+     * Map aliases for a record constructor in SELECT ELEMENT.
+     *
+     * @param overwriteWithGbyKeyVarRefs,
+     *            whether we rewrite the record constructor with mapped group-by key variables.
+     * @param rc,
+     *            the RecordConstructor expression.
+     * @throws AsterixException
+     */
+    private void mapForRecordConstructor(Boolean overwriteWithGbyKeyVarRefs, RecordConstructor rc)
+            throws AsterixException {
+        for (FieldBinding binding : rc.getFbList()) {
+            Expression leftExpr = binding.getLeftExpr();
+            // We only need to deal with the case that the left expression (for a field name) is
+            // a string literal. Otherwise, it is different from a column alias in a projection
+            // (e.g., foo.name AS name) in regular SQL SELECT.
+            if (leftExpr.getKind() == Kind.LITERAL_EXPRESSION) {
+                LiteralExpr literalExpr = (LiteralExpr) leftExpr;
+                if (literalExpr.getValue().getLiteralType() == Literal.Type.STRING) {
+                    String fieldName = literalExpr.getValue().getStringValue();
+                    VariableExpr columnAlias = new VariableExpr(
+                            SqlppVariableUtil.toInternalVariableIdentifier(fieldName));
+                    VariableSubstitutionEnvironment env = scopeChecker.getCurrentScope()
+                            .getVarSubstitutionEnvironment();
+                    if (overwriteWithGbyKeyVarRefs) {
+                        // Rewrites the field value expression by the mapped grouping key
+                        // (for the column alias) if there exists such a mapping.
+                        Expression gbyKey = (Expression) SqlppRewriteUtil.deepCopy(env.findSubstituion(columnAlias));
+                        if (gbyKey != null) {
+                            binding.setRightExpr(gbyKey);
+                        }
+                    } else {
+                        // If this is the first pass, map a field name (i.e., column alias) to the field expression.
+                        scopeChecker.getCurrentScope().addSymbolExpressionMappingToScope(columnAlias,
+                                binding.getRightExpr());
+                    }
+                }
+            }
+        }
+    }
+
     @Override
-    public Void visit(SelectRegular selectRegular, Boolean arg) throws AsterixException {
+    public Void visit(SelectRegular selectRegular, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         for (Projection projection : selectRegular.getProjections()) {
-            projection.accept(this, arg);
+            projection.accept(this, overwriteWithGbyKeyVarRefs);
         }
         return null;
     }
 
     @Override
-    public Void visit(SelectSetOperation selectSetOperation, Boolean arg) throws AsterixException {
-        selectSetOperation.getLeftInput().accept(this, arg);
+    public Void visit(SelectSetOperation selectSetOperation, Boolean overwriteWithGbyKeyVarRefs)
+            throws AsterixException {
+        selectSetOperation.getLeftInput().accept(this, overwriteWithGbyKeyVarRefs);
         for (SetOperationRight right : selectSetOperation.getRightInputs()) {
-            right.getSetOperationRightInput().accept(this, arg);
+            right.getSetOperationRightInput().accept(this, overwriteWithGbyKeyVarRefs);
         }
         return null;
     }
 
     @Override
-    public Void visit(SelectExpression selectExpression, Boolean arg) throws AsterixException {
+    public Void visit(SelectExpression selectExpression, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         scopeChecker.createNewScope();
 
         // Visits let bindings.
         if (selectExpression.hasLetClauses()) {
             for (LetClause lc : selectExpression.getLetList()) {
-                lc.accept(this, arg);
+                lc.accept(this, overwriteWithGbyKeyVarRefs);
             }
         }
 
         // Visits selectSetOperation.
-        selectExpression.getSelectSetOperation().accept(this, arg);
+        selectExpression.getSelectSetOperation().accept(this, overwriteWithGbyKeyVarRefs);
 
         // Visits order by.
         if (selectExpression.hasOrderby()) {
-            selectExpression.getOrderbyClause().accept(this, arg);
+            selectExpression.getOrderbyClause().accept(this, overwriteWithGbyKeyVarRefs);
         }
 
         // Visits limit.
         if (selectExpression.hasLimit()) {
-            selectExpression.getLimitClause().accept(this, arg);
+            selectExpression.getLimitClause().accept(this, overwriteWithGbyKeyVarRefs);
         }
 
         // Exits the scope that were entered within this select expression
@@ -250,9 +295,9 @@
     }
 
     @Override
-    public Void visit(LetClause letClause, Boolean rewrite) throws AsterixException {
+    public Void visit(LetClause letClause, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         VariableSubstitutionEnvironment env = scopeChecker.getCurrentScope().getVarSubstitutionEnvironment();
-        if (rewrite) {
+        if (overwriteWithGbyKeyVarRefs) {
             Expression newBindExpr = (Expression) SqlppVariableSubstitutionUtil
                     .substituteVariableWithoutContext(letClause.getBindingExpr(), env);
             letClause.setBindingExpr(newBindExpr);
@@ -264,26 +309,26 @@
     }
 
     @Override
-    public Void visit(OrderbyClause oc, Boolean arg) throws AsterixException {
+    public Void visit(OrderbyClause oc, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         VariableSubstitutionEnvironment env = scopeChecker.getCurrentScope().getVarSubstitutionEnvironment();
         List<Expression> orderExprs = new ArrayList<Expression>();
         for (Expression orderExpr : oc.getOrderbyList()) {
             orderExprs.add((Expression) SqlppVariableSubstitutionUtil.substituteVariableWithoutContext(orderExpr, env));
-            orderExpr.accept(this, arg);
+            orderExpr.accept(this, overwriteWithGbyKeyVarRefs);
         }
         oc.setOrderbyList(orderExprs);
         return null;
     }
 
     @Override
-    public Void visit(GroupbyClause gc, Boolean arg) throws AsterixException {
+    public Void visit(GroupbyClause gc, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         VariableSubstitutionEnvironment env = scopeChecker.getCurrentScope().getVarSubstitutionEnvironment();
         Map<VariableExpr, VariableExpr> oldGbyExprsToNewGbyVarMap = new HashMap<>();
         for (GbyVariableExpressionPair gbyVarExpr : gc.getGbyPairList()) {
             Expression oldGbyExpr = gbyVarExpr.getExpr();
             Expression newExpr = (Expression) SqlppVariableSubstitutionUtil.substituteVariableWithoutContext(oldGbyExpr,
                     env);
-            newExpr.accept(this, arg);
+            newExpr.accept(this, overwriteWithGbyKeyVarRefs);
             gbyVarExpr.setExpr(newExpr);
             if (gbyVarExpr.getVar() == null) {
                 gbyVarExpr.setVar(new VariableExpr(context.newVariable()));
@@ -305,50 +350,50 @@
     }
 
     @Override
-    public Void visit(LimitClause limitClause, Boolean arg) throws AsterixException {
-        limitClause.getLimitExpr().accept(this, arg);
+    public Void visit(LimitClause limitClause, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
+        limitClause.getLimitExpr().accept(this, overwriteWithGbyKeyVarRefs);
         return null;
     }
 
     @Override
-    public Void visit(HavingClause havingClause, Boolean arg) throws AsterixException {
+    public Void visit(HavingClause havingClause, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         VariableSubstitutionEnvironment env = scopeChecker.getCurrentScope().getVarSubstitutionEnvironment();
         Expression newFilterExpr = (Expression) SqlppVariableSubstitutionUtil
                 .substituteVariableWithoutContext(havingClause.getFilterExpression(), env);
-        newFilterExpr.accept(this, arg);
+        newFilterExpr.accept(this, overwriteWithGbyKeyVarRefs);
         havingClause.setFilterExpression(newFilterExpr);
         return null;
     }
 
     @Override
-    public Void visit(Query q, Boolean arg) throws AsterixException {
-        q.getBody().accept(this, arg);
+    public Void visit(Query q, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
+        q.getBody().accept(this, overwriteWithGbyKeyVarRefs);
         return null;
     }
 
     @Override
-    public Void visit(FunctionDecl fd, Boolean arg) throws AsterixException {
+    public Void visit(FunctionDecl fd, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         scopeChecker.createNewScope();
-        fd.getFuncBody().accept(this, arg);
+        fd.getFuncBody().accept(this, overwriteWithGbyKeyVarRefs);
         scopeChecker.removeCurrentScope();
         return null;
     }
 
     @Override
-    public Void visit(LiteralExpr l, Boolean arg) throws AsterixException {
+    public Void visit(LiteralExpr l, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         return null;
     }
 
     @Override
-    public Void visit(ListConstructor lc, Boolean arg) throws AsterixException {
+    public Void visit(ListConstructor lc, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         for (Expression expr : lc.getExprList()) {
-            expr.accept(this, arg);
+            expr.accept(this, overwriteWithGbyKeyVarRefs);
         }
         return null;
     }
 
     @Override
-    public Void visit(RecordConstructor rc, Boolean rewrite) throws AsterixException {
+    public Void visit(RecordConstructor rc, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         for (FieldBinding binding : rc.getFbList()) {
             binding.getLeftExpr().accept(this, false);
             binding.getRightExpr().accept(this, false);
@@ -356,87 +401,62 @@
         return null;
     }
 
-    private void mapForRecordConstructor(Boolean initPhase, RecordConstructor rc) throws AsterixException {
-        for (FieldBinding binding : rc.getFbList()) {
-            Expression leftExpr = binding.getLeftExpr();
-            if (leftExpr.getKind() == Kind.LITERAL_EXPRESSION) {
-                LiteralExpr literalExpr = (LiteralExpr) leftExpr;
-                if (literalExpr.getValue().getLiteralType() == Literal.Type.STRING) {
-                    String fieldName = literalExpr.getValue().getStringValue();
-                    VariableExpr columnAlias = new VariableExpr(
-                            SqlppVariableUtil.toInternalVariableIdentifier(fieldName));
-                    VariableSubstitutionEnvironment env = scopeChecker.getCurrentScope()
-                            .getVarSubstitutionEnvironment();
-                    if (initPhase) {
-                        scopeChecker.getCurrentScope().addSymbolExpressionMappingToScope(columnAlias,
-                                binding.getRightExpr());
-                    } else {
-                        Expression gbyKey = (Expression) SqlppRewriteUtil.deepCopy(env.findSubstituion(columnAlias));
-                        if (gbyKey != null) {
-                            binding.setRightExpr(gbyKey);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
     @Override
-    public Void visit(OperatorExpr operatorExpr, Boolean arg) throws AsterixException {
+    public Void visit(OperatorExpr operatorExpr, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         for (Expression expr : operatorExpr.getExprList()) {
-            expr.accept(this, arg);
+            expr.accept(this, overwriteWithGbyKeyVarRefs);
         }
         return null;
     }
 
     @Override
-    public Void visit(IfExpr ifExpr, Boolean arg) throws AsterixException {
-        ifExpr.getCondExpr().accept(this, arg);
-        ifExpr.getThenExpr().accept(this, arg);
-        ifExpr.getElseExpr().accept(this, arg);
+    public Void visit(IfExpr ifExpr, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
+        ifExpr.getCondExpr().accept(this, overwriteWithGbyKeyVarRefs);
+        ifExpr.getThenExpr().accept(this, overwriteWithGbyKeyVarRefs);
+        ifExpr.getElseExpr().accept(this, overwriteWithGbyKeyVarRefs);
         return null;
     }
 
     @Override
-    public Void visit(QuantifiedExpression qe, Boolean arg) throws AsterixException {
+    public Void visit(QuantifiedExpression qe, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         for (QuantifiedPair pair : qe.getQuantifiedList()) {
-            pair.getExpr().accept(this, arg);
+            pair.getExpr().accept(this, overwriteWithGbyKeyVarRefs);
         }
-        qe.getSatisfiesExpr().accept(this, arg);
+        qe.getSatisfiesExpr().accept(this, overwriteWithGbyKeyVarRefs);
         return null;
     }
 
     @Override
-    public Void visit(CallExpr callExpr, Boolean arg) throws AsterixException {
+    public Void visit(CallExpr callExpr, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         for (Expression expr : callExpr.getExprList()) {
-            expr.accept(this, arg);
+            expr.accept(this, overwriteWithGbyKeyVarRefs);
         }
         return null;
     }
 
     @Override
-    public Void visit(VariableExpr varExpr, Boolean arg) throws AsterixException {
+    public Void visit(VariableExpr varExpr, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
         return null;
     }
 
     @Override
-    public Void visit(UnaryExpr u, Boolean arg) throws AsterixException {
-        u.getExpr().accept(this, arg);
+    public Void visit(UnaryExpr u, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
+        u.getExpr().accept(this, overwriteWithGbyKeyVarRefs);
         return null;
     }
 
     @Override
-    public Void visit(FieldAccessor fa, Boolean arg) throws AsterixException {
-        fa.getExpr().accept(this, arg);
+    public Void visit(FieldAccessor fa, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
+        fa.getExpr().accept(this, overwriteWithGbyKeyVarRefs);
         return null;
     }
 
     @Override
-    public Void visit(IndexAccessor ia, Boolean arg) throws AsterixException {
-        ia.getExpr().accept(this, arg);
+    public Void visit(IndexAccessor ia, Boolean overwriteWithGbyKeyVarRefs) throws AsterixException {
+        ia.getExpr().accept(this, overwriteWithGbyKeyVarRefs);
         Expression indexExpr = ia.getExpr();
         if (indexExpr != null) {
-            indexExpr.accept(this, arg);
+            indexExpr.accept(this, overwriteWithGbyKeyVarRefs);
         }
         return null;
     }
