15 package com.cloudera.impala.analysis;
17 import java.util.ArrayList;
18 import java.util.HashMap;
20 import jline.internal.Preconditions;
27 import com.cloudera.impala.thrift.TFunctionBinaryType;
28 import com.cloudera.impala.thrift.TSymbolType;
46 HashMap<CreateFunctionStmtBase.OptArg, String> optArgs) {
47 super(fnName, args, retTypeDef, location, ifNotExists, optArgs);
52 super.analyze(analyzer);
53 Preconditions.checkNotNull(
fn_);
57 if (udf.getBinaryType() == TFunctionBinaryType.HIVE) {
58 if (!udf.getReturnType().isScalarType()) {
60 + udf.getReturnType().toSql());
62 if (udf.getReturnType().isTimestamp()) {
64 "Hive UDFs that use TIMESTAMP are not yet supported.");
66 if (udf.getReturnType().isDecimal()) {
68 "Hive UDFs that use DECIMAL are not yet supported.");
70 for (
int i = 0; i < udf.getNumArgs(); ++i) {
71 if (!udf.getArgs()[i].isScalarType()) {
73 + udf.getArgs()[i].toSql());
75 if (udf.getArgs()[i].isTimestamp()) {
77 "Hive UDFs that use TIMESTAMP are not yet supported.");
79 if (udf.getArgs()[i].isDecimal()) {
81 "Hive UDFs that use DECIMAL are not yet supported.");
92 for (
int i = 0; i < udf.getNumArgs(); ++i) {
102 udf.setSymbolName(udf.lookupSymbol(
104 udf.hasVarArgs(), udf.getArgs()));
108 if (prepareFn != null) {
109 udf.setPrepareFnSymbol(udf.lookupSymbol(prepareFn, TSymbolType.UDF_PREPARE));
112 if (closeFn != null) {
113 udf.setCloseFnSymbol(udf.lookupSymbol(closeFn, TSymbolType.UDF_CLOSE));
123 StringBuilder sb =
new StringBuilder(
"CREATE ");
124 sb.append(
"FUNCTION ");
126 sb.append(udf.signatureString())
127 .append(
" RETURNS ").append(udf.getReturnType())
128 .append(
" LOCATION ").append(udf.getLocation())
129 .append(
" SYMBOL=").append(udf.getSymbolName());
136 boolean hasVarArgs) {
void checkOptArgNotSet(OptArg key)
String checkAndGetOptArg(OptArg key)
Function createFunction(FunctionName fnName, ArrayList< Type > argTypes, Type retType, boolean hasVarArgs)
CreateUdfStmt(FunctionName fnName, FunctionArgs args, TypeDef retTypeDef, HdfsUri location, boolean ifNotExists, HashMap< CreateFunctionStmtBase.OptArg, String > optArgs)
void analyze(Analyzer analyzer)
final boolean ifNotExists_