Fix variable arguments bug in UDAF (#1523)
This commit is contained in:
@ -150,8 +150,8 @@ public class CreateFunctionStmt extends DdlStmt {
|
||||
private void analyzeUda() throws AnalysisException {
|
||||
AggregateFunction.AggregateFunctionBuilder builder = AggregateFunction.AggregateFunctionBuilder.createUdfBuilder();
|
||||
|
||||
builder.name(functionName).argsType(argsDef.getArgTypes()).retType(returnType.getType())
|
||||
.intermediateType(intermediateType.getType()).objectFile(objectFile);
|
||||
builder.name(functionName).argsType(argsDef.getArgTypes()).retType(returnType.getType()).
|
||||
hasVarArgs(argsDef.isVariadic()).intermediateType(intermediateType.getType()).objectFile(objectFile);
|
||||
String initFnSymbol = properties.get(INIT_KEY);
|
||||
if (initFnSymbol == null) {
|
||||
throw new AnalysisException("No 'init_fn' in properties");
|
||||
|
||||
@ -177,11 +177,11 @@ public class AggregateFunction extends Function {
|
||||
|
||||
// Used to create UDAF
|
||||
public AggregateFunction(FunctionName fnName, Type[] argTypes,
|
||||
Type retType, Type intermediateType, String location,
|
||||
Type retType, boolean hasVarArgs, Type intermediateType, String location,
|
||||
String initFnSymbol, String updateFnSymbol, String mergeFnSymbol,
|
||||
String serializeFnSymbol, String finalizeFnSymbol,
|
||||
String getValueFnSymbol, String removeFnSymbol) {
|
||||
super(fnName, argTypes, retType, false);
|
||||
super(fnName, argTypes, retType, hasVarArgs);
|
||||
this.setLocation(new HdfsURI(location));
|
||||
this.intermediateType = (intermediateType.equals(retType)) ? null : intermediateType;
|
||||
this.updateFnSymbol = updateFnSymbol;
|
||||
@ -202,6 +202,7 @@ public class AggregateFunction extends Function {
|
||||
FunctionName name;
|
||||
Type[] argTypes;
|
||||
Type retType;
|
||||
boolean hasVarArgs;
|
||||
Type intermediateType;
|
||||
String objectFile;
|
||||
String initFnSymbol;
|
||||
@ -235,6 +236,11 @@ public class AggregateFunction extends Function {
|
||||
return this;
|
||||
}
|
||||
|
||||
public AggregateFunctionBuilder hasVarArgs(boolean hasVarArgs) {
|
||||
this.hasVarArgs = hasVarArgs;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AggregateFunctionBuilder intermediateType(Type type) {
|
||||
this.intermediateType = type;
|
||||
return this;
|
||||
@ -281,8 +287,8 @@ public class AggregateFunction extends Function {
|
||||
}
|
||||
|
||||
public AggregateFunction build() {
|
||||
AggregateFunction fn = new AggregateFunction(name, argTypes, retType, intermediateType, objectFile,
|
||||
initFnSymbol, updateFnSymbol, mergeFnSymbol,
|
||||
AggregateFunction fn = new AggregateFunction(name, argTypes, retType, hasVarArgs, intermediateType,
|
||||
objectFile, initFnSymbol, updateFnSymbol, mergeFnSymbol,
|
||||
serializeFnSymbol, finalizeFnSymbol,
|
||||
getValueFnSymbol, removeFnSymbol);
|
||||
fn.setBinaryType(binaryType);
|
||||
|
||||
Reference in New Issue
Block a user