@Override public RowExpression visitLambda(LambdaDefinitionExpression lambda, Void context) { return new LambdaDefinitionExpression( lambda.getArgumentTypes(), lambda.getArguments(), lambda.getBody().accept(this, context)); }
private static RowExpression changeType(RowExpression value, Type targetType) { ChangeTypeVisitor visitor = new ChangeTypeVisitor(targetType); return value.accept(visitor, null); }
@Override protected RowExpression visitCast(Cast node, Void context) { RowExpression value = process(node.getExpression(), context); if (node.isTypeOnly()) { return changeType(value, getType(node)); } if (node.isSafe()) { return call(tryCastSignature(getType(node), value.getType()), getType(node), value); } return call(castSignature(getType(node), value.getType()), getType(node), value); }
@Override protected RowExpression visitIsNullPredicate(IsNullPredicate node, Void context) { RowExpression expression = process(node.getValue(), context); return call(Signatures.isNullSignature(expression.getType()), BOOLEAN, expression); }
@Override protected RowExpression visitNullIfExpression(NullIfExpression node, Void context) { RowExpression first = process(node.getFirst(), context); RowExpression second = process(node.getSecond(), context); return call( nullIfSignature(getType(node), first.getType(), second.getType()), getType(node), first, second); }
@Override protected RowExpression visitSubscriptExpression(SubscriptExpression node, Void context) { RowExpression base = process(node.getBase(), context); RowExpression index = process(node.getIndex(), context); return call( subscriptSignature(getType(node), base.getType(), index.getType()), getType(node), base, index); }
@Override protected RowExpression visitArithmeticBinary(ArithmeticBinaryExpression node, Void context) { RowExpression left = process(node.getLeft(), context); RowExpression right = process(node.getRight(), context); return call( arithmeticExpressionSignature(node.getOperator(), getType(node), left.getType(), right.getType()), getType(node), left, right); }
@Override protected RowExpression visitBetweenPredicate(BetweenPredicate node, Void context) { RowExpression value = process(node.getValue(), context); RowExpression min = process(node.getMin(), context); RowExpression max = process(node.getMax(), context); return call( betweenSignature(value.getType(), min.getType(), max.getType()), BOOLEAN, value, min, max); }
@Override protected RowExpression visitComparisonExpression(ComparisonExpression node, Void context) { RowExpression left = process(node.getLeft(), context); RowExpression right = process(node.getRight(), context); return call( comparisonExpressionSignature(node.getOperator(), left.getType(), right.getType()), BOOLEAN, left, right); }
@Override protected RowExpression visitTryExpression(TryExpression node, Void context) { return call(Signatures.trySignature(getType(node)), getType(node), process(node.getInnerExpression(), context)); }
@Override protected RowExpression visitNotExpression(NotExpression node, Void context) { return call(Signatures.notSignature(), BOOLEAN, process(node.getValue(), context)); }
@Override protected RowExpression visitLogicalBinaryExpression(LogicalBinaryExpression node, Void context) { return call( logicalExpressionSignature(node.getOperator()), BOOLEAN, process(node.getLeft(), context), process(node.getRight(), context)); }
@Override public Void visitCall(CallExpression call, Context context) { for (RowExpression rowExpression : call.getArguments()) { rowExpression.accept(this, context); } return null; }
@Override protected RowExpression visitIsNotNullPredicate(IsNotNullPredicate node, Void context) { RowExpression expression = process(node.getValue(), context); return call( Signatures.notSignature(), BOOLEAN, call(Signatures.isNullSignature(expression.getType()), BOOLEAN, ImmutableList.of(expression))); }
@Override public RowExpression visitLambda(LambdaDefinitionExpression lambda, Void context) { return new LambdaDefinitionExpression(lambda.getArgumentTypes(), lambda.getArguments(), lambda.getBody().accept(this, context)); }
@Override public RowExpression visitLambda(LambdaDefinitionExpression lambda, Void context) { return new LambdaDefinitionExpression(lambda.getArgumentTypes(), lambda.getArguments(), lambda.getBody().accept(this, context)); }