public PatternMatchPredicateEval(EvalType evalType, boolean not, EvalNode predicand, ConstEval pattern, boolean caseInsensitive) { super(evalType, predicand, pattern); this.not = not; this.pattern = pattern.getValue().asChars(); this.caseInsensitive = caseInsensitive; }
@Override protected EvalNode visitConst(Object o, ConstEval evalNode, Stack<EvalNode> stack) { exprs.push(convertDatumToExpr(evalNode.getValueType().kind(), evalNode.getValue())); return super.visitConst(o, evalNode, stack); }
@Override protected EvalNode visitConst(Context context, ConstEval constant, Stack<EvalNode> stack) { context.sb.append(convertDatumToSQLLiteral(constant.getValue())).append(" "); return constant; }
context.push(constEval.getValue().asInt4()); break; case INT4: case DATE: context.push(constEval.getValue().asInt4()); break; case INT8: case TIMESTAMP: case TIME: context.push(constEval.getValue().asInt8()); break; case FLOAT4: context.push(constEval.getValue().asFloat4()); break; case FLOAT8: context.push(constEval.getValue().asFloat8()); break; case CHAR: case TEXT: context.push(constEval.getValue().asChars()); break; case INTERVAL:
@Override protected EvalNode visitConst(Context context, ConstEval constant, Stack<EvalNode> stack) { context.sb.append(convertDatumToSQLLiteral(constant.getValue())).append(" "); return constant; }
context.push(constEval.getValue().asInt4()); break; case INT4: case DATE: context.push(constEval.getValue().asInt4()); break; case INT8: case TIMESTAMP: case TIME: context.push(constEval.getValue().asInt8()); break; case FLOAT4: context.push(constEval.getValue().asFloat4()); break; case FLOAT8: context.push(constEval.getValue().asFloat8()); break; case CHAR: case TEXT: context.push(constEval.getValue().asChars()); break; case INTERVAL:
public PatternMatchPredicateEval(EvalType evalType, boolean not, EvalNode predicand, ConstEval pattern, boolean caseInsensitive) { super(evalType, predicand, pattern); this.not = not; this.pattern = pattern.getValue().asChars(); this.caseInsensitive = caseInsensitive; }
@Override public EvalNode visitConst(EvalTreeProtoBuilderContext context, ConstEval constant, Stack<EvalNode> stack) { PlanProto.EvalNode.Builder builder = createEvalBuilder(context, constant); builder.setConst(PlanProto.ConstEval.newBuilder().setValue(serialize(constant.getValue()))); context.treeBuilder.addNodes(builder); return constant; }
@Override public EvalNode bind(EvalContext evalContext, Schema schema) { super.bind(evalContext, schema); if (begin.getType() == EvalType.CONST && end.getType() == EvalType.CONST) { Datum beginValue = ((ConstEval)begin).getValue(); Datum endValue = ((ConstEval)end).getValue(); if (symmetric || beginValue.compareTo(endValue) <= 0) { checker = new ConstantChecker(not, predicand, beginValue, endValue); } else { checker = new AsymmetricChecker(not, predicand, begin, end); } } else { if (symmetric) { checker = new SymmetricChecker(not, predicand, begin, end); } else { checker = new AsymmetricChecker(not, predicand, begin, end); } } checker.bind(evalContext, schema); return this; }
@Override public EvalNode visitConst(EvalTreeProtoBuilderContext context, ConstEval constant, Stack<EvalNode> stack) { PlanProto.EvalNode.Builder builder = createEvalBuilder(context, constant); builder.setConst(PlanProto.ConstEval.newBuilder().setValue(serialize(constant.getValue()))); context.treeBuilder.addNodes(builder); return constant; }
@Override public EvalNode bind(EvalContext evalContext, Schema schema) { super.bind(evalContext, schema); if (begin.getType() == EvalType.CONST && end.getType() == EvalType.CONST) { Datum beginValue = ((ConstEval)begin).getValue(); Datum endValue = ((ConstEval)end).getValue(); if (symmetric || beginValue.compareTo(endValue) <= 0) { checker = new ConstantChecker(not, predicand, beginValue, endValue); } else { checker = new AsymmetricChecker(not, predicand, begin, end); } } else { if (symmetric) { checker = new SymmetricChecker(not, predicand, begin, end); } else { checker = new AsymmetricChecker(not, predicand, begin, end); } } checker.bind(evalContext, schema); return this; }
private static void checkDivisionByZero(VerificationState state, BinaryEval evalNode) { if (evalNode.getRightExpr().getType() == EvalType.CONST) { ConstEval constEval = evalNode.getRightExpr(); if (constEval.getValue().asFloat8() == 0) { state.addVerification(new TajoException(Errors.ResultCode.DIVISION_BY_ZERO, evalNode.toString())); } } }
private static void checkDivisionByZero(VerificationState state, BinaryEval evalNode) { if (evalNode.getRightExpr().getType() == EvalType.CONST) { ConstEval constEval = evalNode.getRightExpr(); if (constEval.getValue().asFloat8() == 0) { state.addVerification(new TajoException(Errors.ResultCode.DIVISION_BY_ZERO, evalNode.toString())); } } }
@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 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()); } }
private EvalNode visitPatternMatchPredicate(Context ctx, Stack<Expr> stack, PatternMatchPredicate expr) throws TajoException { EvalNode field = visit(ctx, stack, expr.getPredicand()); ConstEval pattern = (ConstEval) visit(ctx, stack, expr.getPattern()); // A pattern is a const value in pattern matching predicates. // In a binary expression, the result is always null if a const value in left or right side is null. if (pattern.getValue() instanceof NullDatum) { return new ConstEval(NullDatum.get()); } else { if (expr.getType() == OpType.LikePredicate) { return new LikePredicateEval(expr.isNot(), field, pattern, expr.isCaseInsensitive()); } else if (expr.getType() == OpType.SimilarToPredicate) { return new SimilarToPredicateEval(expr.isNot(), field, pattern); } else { return new RegexPredicateEval(expr.isNot(), field, pattern, expr.isCaseInsensitive()); } } }
private EvalNode visitPatternMatchPredicate(Context ctx, Stack<Expr> stack, PatternMatchPredicate expr) throws TajoException { EvalNode field = visit(ctx, stack, expr.getPredicand()); ConstEval pattern = (ConstEval) visit(ctx, stack, expr.getPattern()); // A pattern is a const value in pattern matching predicates. // In a binary expression, the result is always null if a const value in left or right side is null. if (pattern.getValue() instanceof NullDatum) { return new ConstEval(NullDatum.get()); } else { if (expr.getType() == OpType.LikePredicate) { return new LikePredicateEval(expr.isNot(), field, pattern, expr.isCaseInsensitive()); } else if (expr.getType() == OpType.SimilarToPredicate) { return new SimilarToPredicateEval(expr.isNot(), field, pattern); } else { return new RegexPredicateEval(expr.isNot(), field, pattern, expr.isCaseInsensitive()); } } }
ConstEval newConst = new ConstEval(DatumFactory.cast(original.getValue(), toType, ctx.timeZone)); return newConst;
ConstEval newConst = new ConstEval(DatumFactory.cast(original.getValue(), toType, ctx.timeZone)); return newConst;