/**
  * It returns an original column name if it is aliased column reference. Otherwise, it will return
  * NULL.
  */
 public String checkAndGetIfAliasedColumn(String name) {
   Expr expr = getExpr(name);
   if (expr != null && expr.getType() == OpType.Column) {
     ColumnReferenceExpr column = (ColumnReferenceExpr) expr;
     if (!column.getCanonicalName().equals(name)) {
       return column.getCanonicalName();
     }
   }
   return null;
 }
Пример #2
0
 @Override
 public Expr visitColumnReference(
     ExprNormalizedResult ctx, Stack<Expr> stack, ColumnReferenceExpr expr)
     throws PlanningException {
   // normalize column references.
   if (!expr.hasQualifier()) {
     if (ctx.block.namedExprsMgr.contains(expr.getCanonicalName())) {
       NamedExpr namedExpr = ctx.block.namedExprsMgr.getNamedExpr(expr.getCanonicalName());
       return new ColumnReferenceExpr(namedExpr.getAlias());
     } else {
       String normalized = ctx.plan.getNormalizedColumnName(ctx.block, expr);
       expr.setName(normalized);
     }
   }
   return expr;
 }