public static CallExpression call(Signature signature, Type returnType, List<RowExpression> arguments) { return new CallExpression(signature, returnType, arguments); }
@Override public RowExpression visitCall(CallExpression call, Void context) { return new CallExpression( call.getSignature(), call.getType(), call.getArguments().stream() .map(expression -> expression.accept(this, context)) .collect(toImmutableList())); }
@Override public RowExpression visitCall(CallExpression call, Void context) { return new CallExpression(call.getSignature(), targetType, call.getArguments()); }
public static List<RowExpression> flattenNestedCallArgs(CallExpression call) { String callName = call.getSignature().getName(); ImmutableList.Builder<RowExpression> newArguments = ImmutableList.builder(); for (RowExpression argument : call.getArguments()) { if (argument instanceof CallExpression && callName.equals(((CallExpression) argument).getSignature().getName())) { // same call type, so flatten the args newArguments.addAll(flattenNestedCallArgs((CallExpression) argument)); } else { newArguments.add(argument); } } return newArguments.build(); }
if (call.getArguments().get(0) instanceof CallExpression) { CallExpression innerCall = (CallExpression) call.getArguments().get(0); if (innerCall.getSignature().getName().equals("json_parse")) { checkArgument(innerCall.getType().equals(JSON)); checkArgument(innerCall.getArguments().size() == 1); TypeSignature returnType = call.getSignature().getReturnType(); if (returnType.getBase().equals(ARRAY)) { return call( returnType, ImmutableList.of(parseTypeSignature(VARCHAR))), call.getType(), innerCall.getArguments()); returnType, ImmutableList.of(parseTypeSignature(VARCHAR))), call.getType(), innerCall.getArguments()); returnType, ImmutableList.of(parseTypeSignature(VARCHAR))), call.getType(), innerCall.getArguments()); registry.getCoercion(call.getArguments().get(0).getType(), call.getType()), call.getType(), call.getArguments());
for (CallExpression tryExpression : tryExpressions) { Parameter session = arg("session", ConnectorSession.class); List<Parameter> blocks = toBlockParameters(getInputChannels(tryExpression.getArguments())); Parameter position = arg("position", int.class); Parameter wasNullVariable = arg("wasNull", boolean.class); methodPrefix + "_try_" + methodId, inputParameters, Primitives.wrap(tryExpression.getType().getJavaType()), tryExpression, callSiteBinder);
@Override public Void visitCall(CallExpression call, Void context) { builder.add(call); for (RowExpression argument : call.getArguments()) { argument.accept(this, context); } return null; }
@Override public BytecodeNode generateExpression(Signature signature, BytecodeGeneratorContext context, Type returnType, List<RowExpression> arguments) { checkArgument(arguments.size() == 1, "try methods only contain a single expression"); checkArgument(getOnlyElement(arguments) instanceof CallExpression, "try methods must contain a call expression"); CallExpression innerCallExpression = (CallExpression) getOnlyElement(arguments); checkState(tryMethodsMap.containsKey(innerCallExpression), "try methods map does not contain this try call"); BytecodeBlock bytecodeBlock = new BytecodeBlock() .comment("load required variables") .getVariable(context.getScope().getVariable("this")); inputParameters.stream() .forEach(bytecodeBlock::getVariable); bytecodeBlock.comment("call dynamic try method: " + tryMethodsMap.get(innerCallExpression).getName()) .invokeVirtual(tryMethodsMap.get(innerCallExpression)) .append(unboxPrimitiveIfNecessary(context.getScope(), Primitives.wrap(innerCallExpression.getType().getJavaType()))); return bytecodeBlock; }
if (call.getSignature().getName().equals(CAST)) { call = rewriteCast(call); Signature signature = call.getSignature(); checkState(call.getArguments().size() == 3, "IF function should have 3 arguments. Get " + call.getArguments().size()); RowExpression optimizedOperand = call.getArguments().get(0).accept(this, context); if (optimizedOperand instanceof ConstantExpression) { ConstantExpression constantOperand = (ConstantExpression) optimizedOperand; checkState(constantOperand.getType().equals(BOOLEAN), "Operand of IF function should be BOOLEAN type. Get type " + constantOperand.getType().getDisplayName()); if (Boolean.TRUE.equals(constantOperand.getValue())) { return call.getArguments().get(1).accept(this, context); return call.getArguments().get(2).accept(this, context); List<RowExpression> arguments = call.getArguments().stream() .map(argument -> argument.accept(this, null)) .collect(toImmutableList()); return call(signature, call.getType(), arguments); checkState(call.getArguments().size() >= 1, BIND + " function should have at least 1 argument. Got " + call.getArguments().size()); for (RowExpression argument : call.getArguments()) { RowExpression optimizedArgument = argument.accept(this, context); if (!(optimizedArgument instanceof ConstantExpression)) { return call(signature, call.getType(), optimizedArgumentsBuilder.build()); case DEREFERENCE:
@Override public RowExpression visitCall(CallExpression call, Void context) { return new CallExpression(call.getSignature(), targetType, call.getArguments()); }
@Override public Boolean visitCall(CallExpression call, Void context) { Signature signature = call.getSignature(); if (registry.isRegistered(signature) && !registry.getScalarFunctionImplementation(signature).isDeterministic()) { return false; } return call.getArguments().stream() .allMatch(expression -> expression.accept(this, context)); }
@Override public Void visitCall(CallExpression call, Context context) { for (RowExpression rowExpression : call.getArguments()) { rowExpression.accept(this, context); } return null; }
methodPrefix + "_try_" + methodId, inputParameters, Primitives.wrap(tryExpression.getType().getJavaType()), tryExpression, callSiteBinder);
public static CallExpression call(Signature signature, Type returnType, RowExpression... arguments) { return new CallExpression(signature, returnType, Arrays.asList(arguments)); }
call = new CallExpression( call.getSignature(), call.getType(), call.getArguments().stream() .map(expression -> expression.accept(this, context)) .collect(toImmutableList())); String callName = call.getSignature().getName(); return new CallExpression( internalScalarFunction( callName, return new CallExpression( call.getSignature(), call.getType(), ROW_EXPRESSION_ORDERING.sortedCopy(call.getArguments())); return new CallExpression( new Signature( callName.equals(mangleOperatorName(GREATER_THAN)) ? mangleOperatorName(LESS_THAN) : mangleOperatorName(LESS_THAN_OR_EQUAL), SCALAR, call.getSignature().getTypeVariableConstraints(), call.getSignature().getLongVariableConstraints(), call.getSignature().getReturnType(), swapPair(call.getSignature().getArgumentTypes()), false), call.getType(), swapPair(call.getArguments()));
if (call.getSignature().getName().equals(CAST)) { generator = new CastCodeGenerator(); switch (call.getSignature().getName()) { registry); return generator.generateExpression(call.getSignature(), generatorContext, call.getType(), call.getArguments(), context.getOutputBlockVariable());
CallExpression rightCall = (CallExpression) right; return ComparisonChain.start() .compare(leftCall.getSignature().toString(), rightCall.getSignature().toString()) .compare(leftCall.getArguments(), rightCall.getArguments(), argumentComparator) .result();
@Override public Void visitCall(CallExpression call, Void context) { builder.add(call); for (RowExpression argument : call.getArguments()) { argument.accept(this, context); } return null; }
@Test public void testNoCaching() { ImmutableList.Builder<RowExpression> projectionsBuilder = ImmutableList.builder(); ArrayType arrayType = new ArrayType(VARCHAR); Signature signature = new Signature("concat", SCALAR, arrayType.getTypeSignature(), arrayType.getTypeSignature(), arrayType.getTypeSignature()); projectionsBuilder.add(new CallExpression(signature, arrayType, ImmutableList.of(field(0, arrayType), field(1, arrayType)))); ImmutableList<RowExpression> projections = projectionsBuilder.build(); PageProcessor pageProcessor = compiler.compilePageProcessor(Optional.empty(), projections).get(); PageProcessor pageProcessor2 = compiler.compilePageProcessor(Optional.empty(), projections).get(); assertTrue(pageProcessor != pageProcessor2); }
call = new CallExpression( call.getSignature(), call.getType(), call.getArguments().stream() .map(expression -> expression.accept(this, context)) .collect(toImmutableList())); String callName = call.getSignature().getName(); return new CallExpression( internalScalarFunction( callName, return new CallExpression( call.getSignature(), call.getType(), ROW_EXPRESSION_ORDERING.sortedCopy(call.getArguments())); return new CallExpression( new Signature( callName.equals(mangleOperatorName(GREATER_THAN)) ? mangleOperatorName(LESS_THAN) : mangleOperatorName(LESS_THAN_OR_EQUAL), SCALAR, call.getSignature().getTypeParameterRequirements(), call.getSignature().getReturnType(), swapPair(call.getSignature().getArgumentTypes()), false), call.getType(), swapPair(call.getArguments()));