[fix](java-udf) Fix need to restart BE after replacing the jar package in java-udf (#24372)

Fix need to restart BE after replacing the jar package in java-udf
This commit is contained in:
DongLiang-0
2023-09-15 13:30:08 +08:00
committed by GitHub
parent 83d5831ae0
commit 32844b2a5b
2 changed files with 14 additions and 6 deletions

View File

@ -47,6 +47,7 @@ import java.util.stream.Collectors;
*/
public class JavaUdaf extends AggregateFunction implements ExplicitlyCastableSignature, Udf {
private final String dbName;
private final long functionId;
private final TFunctionBinaryType binaryType;
private final FunctionSignature signature;
private final DataType intermediateType;
@ -65,7 +66,8 @@ public class JavaUdaf extends AggregateFunction implements ExplicitlyCastableSig
/**
* Constructor of UDAF
*/
public JavaUdaf(String name, String dbName, TFunctionBinaryType binaryType, FunctionSignature signature,
public JavaUdaf(String name, long functionId, String dbName, TFunctionBinaryType binaryType,
FunctionSignature signature,
DataType intermediateType, NullableMode nullableMode,
String objectFile, String symbol,
String initFn, String updateFn, String mergeFn,
@ -73,6 +75,7 @@ public class JavaUdaf extends AggregateFunction implements ExplicitlyCastableSig
boolean isDistinct, String checkSum, Expression... args) {
super(name, isDistinct, args);
this.dbName = dbName;
this.functionId = functionId;
this.binaryType = binaryType;
this.signature = signature;
this.intermediateType = intermediateType == null ? signature.returnType : intermediateType;
@ -115,7 +118,7 @@ public class JavaUdaf extends AggregateFunction implements ExplicitlyCastableSig
@Override
public JavaUdaf withDistinctAndChildren(boolean isDistinct, List<Expression> children) {
Preconditions.checkArgument(children.size() == this.children.size());
return new JavaUdaf(getName(), dbName, binaryType, signature, intermediateType, nullableMode,
return new JavaUdaf(getName(), functionId, dbName, binaryType, signature, intermediateType, nullableMode,
objectFile, symbol, initFn, updateFn, mergeFn, serializeFn, finalizeFn, getValueFn, removeFn,
isDistinct, checkSum, children.toArray(new Expression[0]));
}
@ -145,7 +148,7 @@ public class JavaUdaf extends AggregateFunction implements ExplicitlyCastableSig
intermediateType = DataType.fromCatalogType(aggregate.getIntermediateType());
}
JavaUdaf udaf = new JavaUdaf(fnName, dbName, aggregate.getBinaryType(), sig,
JavaUdaf udaf = new JavaUdaf(fnName, aggregate.getId(), dbName, aggregate.getBinaryType(), sig,
intermediateType,
aggregate.getNullableMode(),
aggregate.getLocation().getLocation(),
@ -192,6 +195,7 @@ public class JavaUdaf extends AggregateFunction implements ExplicitlyCastableSig
expr.setBinaryType(binaryType);
expr.setNullableMode(nullableMode);
expr.setChecksum(checkSum);
expr.setId(functionId);
return expr;
} catch (Exception e) {
throw new AnalysisException(e.getMessage(), e.getCause());

View File

@ -47,6 +47,7 @@ import java.util.stream.Collectors;
*/
public class JavaUdf extends ScalarFunction implements ExplicitlyCastableSignature, Udf {
private final String dbName;
private final long functionId;
private final TFunctionBinaryType binaryType;
private final FunctionSignature signature;
private final NullableMode nullableMode;
@ -59,11 +60,13 @@ public class JavaUdf extends ScalarFunction implements ExplicitlyCastableSignatu
/**
* Constructor of UDF
*/
public JavaUdf(String name, String dbName, TFunctionBinaryType binaryType, FunctionSignature signature,
public JavaUdf(String name, long functionId, String dbName, TFunctionBinaryType binaryType,
FunctionSignature signature,
NullableMode nullableMode, String objectFile, String symbol, String prepareFn, String closeFn,
String checkSum, Expression... args) {
super(name, args);
this.dbName = dbName;
this.functionId = functionId;
this.binaryType = binaryType;
this.signature = signature;
this.nullableMode = nullableMode;
@ -100,7 +103,7 @@ public class JavaUdf extends ScalarFunction implements ExplicitlyCastableSignatu
@Override
public JavaUdf withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == this.children.size());
return new JavaUdf(getName(), dbName, binaryType, signature, nullableMode,
return new JavaUdf(getName(), functionId, dbName, binaryType, signature, nullableMode,
objectFile, symbol, prepareFn, closeFn, checkSum, children.toArray(new Expression[0]));
}
@ -124,7 +127,7 @@ public class JavaUdf extends ScalarFunction implements ExplicitlyCastableSignatu
(shape) -> ImmutableList.of()))
.toArray(VirtualSlotReference[]::new);
JavaUdf udf = new JavaUdf(fnName, dbName, scalar.getBinaryType(), sig,
JavaUdf udf = new JavaUdf(fnName, scalar.getId(), dbName, scalar.getBinaryType(), sig,
scalar.getNullableMode(),
scalar.getLocation().getLocation(),
scalar.getSymbolName(),
@ -158,6 +161,7 @@ public class JavaUdf extends ScalarFunction implements ExplicitlyCastableSignatu
);
expr.setNullableMode(nullableMode);
expr.setChecksum(checkSum);
expr.setId(functionId);
return expr;
} catch (Exception e) {
throw new AnalysisException(e.getMessage(), e.getCause());