@Override public DataType visitDataType(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, DataTypeExpr expr) throws TajoException { return LogicalPlanner.convertDataType(expr).getDataType(); }
@Override public DataType visitDataType(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, DataTypeExpr expr) throws TajoException { return convert(LogicalPlanner.convertDataType(expr)).getDataType(); }
private static Column convertColumn(ColumnDefinition columnDefinition) { return new Column(columnDefinition.getColumnName(), convertDataType(columnDefinition)); }
private static Column convertColumn(ColumnDefinition columnDefinition) { return new Column(columnDefinition.getColumnName(), convertDataType(columnDefinition)); }
@Override public EvalNode visitCastExpr(Context ctx, Stack<Expr> stack, CastExpr expr) throws TajoException { EvalNode child = super.visitCastExpr(ctx, stack, expr); // if it is a casting operation for a constant value, it will be pre-computed and casted to a constant value. if (child.getType() == EvalType.CONST) { ConstEval constEval = (ConstEval) child; // some cast operation may require earlier evaluation with timezone. return new ConstEval( DatumFactory.cast(constEval.getValue(), LogicalPlanner.convertDataType(expr.getTarget()), ctx.timeZone)); } else { return new CastEval(ctx.queryContext, child, LogicalPlanner.convertDataType(expr.getTarget())); } }
@Override public DataType visitUnaryOperator(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, UnaryOperator expr) throws TajoException { stack.push(expr); DataType dataType = null; switch (expr.getType()) { case IsNullPredicate: case ExistsPredicate: dataType = BOOL_TYPE; break; case Cast: dataType = LogicalPlanner.convertDataType(((CastExpr)expr).getTarget()).getDataType(); break; default: dataType = visit(ctx, stack, expr.getChild()); } return dataType; }
@Override public EvalNode visitCastExpr(Context ctx, Stack<Expr> stack, CastExpr expr) throws TajoException { EvalNode child = super.visitCastExpr(ctx, stack, expr); // if it is a casting operation for a constant value, it will be pre-computed and casted to a constant value. if (child.getType() == EvalType.CONST) { ConstEval constEval = (ConstEval) child; // some cast operation may require earlier evaluation with timezone. return new ConstEval( DatumFactory.cast(constEval.getValue(), LogicalPlanner.convertDataType(expr.getTarget()).getDataType(), ctx.timeZone)); } else { return new CastEval(ctx.queryContext, child, LogicalPlanner.convertDataType(expr.getTarget()).getDataType()); } }
@Override public DataType visitUnaryOperator(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, UnaryOperator expr) throws TajoException { stack.push(expr); DataType dataType; switch (expr.getType()) { case IsNullPredicate: case ExistsPredicate: dataType = BOOL_TYPE; break; case Cast: dataType = convert(LogicalPlanner.convertDataType(((CastExpr)expr).getTarget())).getDataType(); break; default: dataType = visit(ctx, stack, expr.getChild()); } return dataType; }
return Array(convertDataType(dataType.getElementType())); } else if (type == TajoDataTypes.Type.RECORD) { return Record(convertTableElementsSchema(dataType.getNestedRecordTypes())); } else if (type == TajoDataTypes.Type.MAP) { return Map(convertDataType(dataType.getKeyType()), convertDataType(dataType.getValueType())); } else if (type == TajoDataTypes.Type.NUMERIC) { if (dataType.hasLengthOrPrecision() && dataType.hasScale()) {