Package com.facebook.presto.metadata

Examples of com.facebook.presto.metadata.FunctionInfo


        this.metadata = checkNotNull(metadata, "metadata is null");
    }

    public FunctionBinding bindFunction(QualifiedName name, ByteCodeNode getSessionByteCode, List<ByteCodeNode> arguments, List<Type> argumentTypes)
    {
        FunctionInfo function = metadata.resolveFunction(name, argumentTypes, false);
        checkArgument(function != null, "Unknown function %s%s", name, argumentTypes);

        return bindFunction(name.toString(), getSessionByteCode, arguments, function.getFunctionBinder());
    }
View Full Code Here


            ImmutableList.Builder<Type> argumentTypes = ImmutableList.builder();
            for (Expression expression : node.getArguments()) {
                argumentTypes.add(process(expression, context));
            }

            FunctionInfo function = metadata.resolveFunction(node.getName(), argumentTypes.build(), context.isApproximate());
            for (int i = 0; i < node.getArguments().size(); i++) {
                Expression expression = node.getArguments().get(i);
                Type type = function.getArgumentTypes().get(i);
                coerceType(context, expression, type, String.format("Function %s argument %d", function.getHandle(), i));
            }
            resolvedFunctions.put(node, function);

            expressionTypes.put(node, function.getReturnType());

            return function.getReturnType();
        }
View Full Code Here

                {
                    return analysis.getType(input);
                }
            });

            FunctionInfo info = metadata.resolveFunction(windowFunction.getName(), argumentTypes, false);
            if (!info.isWindow()) {
                throw new SemanticException(MUST_BE_WINDOW_FUNCTION, node, "Not a window function: %s", windowFunction.getName());
            }
        }

        analysis.setWindowFunctions(node, windowFunctions);
View Full Code Here

                }
                Type type = expressionTypes.get(expression);
                argumentValues.add(value);
                argumentTypes.add(type);
            }
            FunctionInfo function = metadata.resolveFunction(node.getName(), argumentTypes, false);

            // do not optimize non-deterministic functions
            if (optimize && (!function.isDeterministic() || hasUnresolvedValue(argumentValues))) {
                return new FunctionCall(node.getName(), node.getWindow().orNull(), node.isDistinct(), toExpressions(argumentValues, argumentTypes));
            }
            return invoke(session, function.getScalarFunction(), argumentValues);
        }
View Full Code Here

                {
                    return analysis.getType(input);
                }
            });

            FunctionInfo info = metadata.resolveFunction(windowFunction.getName(), argumentTypes, false);
            if (!info.isWindow()) {
                throw new SemanticException(MUST_BE_WINDOW_FUNCTION, node, "Not a window function: %s", windowFunction.getName());
            }
        }

        analysis.setWindowFunctions(node, windowFunctions);
View Full Code Here

            ImmutableList.Builder<Type> argumentTypes = ImmutableList.builder();
            for (Expression expression : node.getArguments()) {
                argumentTypes.add(process(expression, context));
            }

            FunctionInfo function = metadata.resolveFunction(node.getName(), argumentTypes.build(), context.isApproximate());
            for (int i = 0; i < node.getArguments().size(); i++) {
                Expression expression = node.getArguments().get(i);
                Type type = function.getArgumentTypes().get(i);
                coerceType(context, expression, type, String.format("Function %s argument %d", function.getSignature(), i));
            }
            resolvedFunctions.put(node, function);

            expressionTypes.put(node, function.getReturnType());

            return function.getReturnType();
        }
View Full Code Here

            ImmutableList.Builder<Type> argumentTypes = ImmutableList.builder();
            for (Expression expression : arguments) {
                argumentTypes.add(process(expression, context));
            }

            FunctionInfo operatorInfo;
            try {
                operatorInfo = metadata.resolveOperator(operatorType, argumentTypes.build());
            }
            catch (OperatorNotFoundException e) {
                throw new SemanticException(TYPE_MISMATCH, node, e.getMessage());
            }

            for (int i = 0; i < arguments.length; i++) {
                Expression expression = arguments[i];
                Type type = operatorInfo.getArgumentTypes().get(i);
                coerceType(context, expression, type, String.format("Operator %s argument %d", operatorInfo, i));
            }

            expressionTypes.put(node, operatorInfo.getReturnType());

            return operatorInfo.getReturnType();
        }
View Full Code Here

                {
                    return analysis.getType(input);
                }
            });

            FunctionInfo info = metadata.resolveFunction(windowFunction.getName(), argumentTypes, false);
            if (!info.isWindow()) {
                throw new SemanticException(MUST_BE_WINDOW_FUNCTION, node, "Not a window function: %s", windowFunction.getName());
            }
        }

        analysis.setWindowFunctions(node, windowFunctions);
View Full Code Here

        CompilerContext context = generatorContext.getContext();
        if (argument.getType().equals(UnknownType.UNKNOWN)) {
            return new Block(context).putVariable("wasNull", true).pushJavaDefault(returnType.getJavaType());
        }

        FunctionInfo function = generatorContext
                .getRegistry()
                .getCoercion(argument.getType(), returnType);

        return generatorContext.generateCall(function, ImmutableList.of(generatorContext.generate(argument)));
    }
View Full Code Here

        RowExpression right = arguments.get(1);

        Type leftType = left.getType();
        Type rightType = right.getType();

        FunctionInfo operator = generatorContext
                .getRegistry()
                .resolveOperator(OperatorType.EQUAL, ImmutableList.of(leftType, rightType));

        Binding binding = generatorContext
                .getCallSiteBinder()
                .bind(operator.getMethodHandle());

        ByteCodeNode equalsCall = new Block(context)
                .comment("equals(%s, %s)", leftType, rightType)
                .append(invoke(generatorContext.getContext(), binding));
View Full Code Here

TOP

Related Classes of com.facebook.presto.metadata.FunctionInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.