/** * Adds an expression and returns a reference name. If an alias is given, it specifies the alias * as an reference name. */ public String addNamedExpr(NamedExpr namedExpr) throws PlanningException { if (namedExpr.hasAlias()) { return addExpr(namedExpr.getExpr(), namedExpr.getAlias()); } else { return addExpr(namedExpr.getExpr()); } }
@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; }