[Bug](function) fix function define of Retention inconsist and change some static_cast to assert cast (#19455)
1. fix function define of `Retention` inconsist, this function return tinyint on `FE` and return uint8 on `BE` 2. make assert_cast support cast to derived 3. change some static cast to assert cast 4. support sum(bool)/avg(bool)
This commit is contained in:
@ -819,7 +819,8 @@ public class FunctionCallExpr extends Expr {
|
||||
// SUM and AVG cannot be applied to non-numeric types
|
||||
if ((fnName.getFunction().equalsIgnoreCase("sum")
|
||||
|| fnName.getFunction().equalsIgnoreCase("avg"))
|
||||
&& ((!arg.type.isNumericType() && !arg.type.isNull()) || arg.type.isOnlyMetricType())) {
|
||||
&& ((!arg.type.isNumericType() && !arg.type.isNull() && !arg.type.isBoolean())
|
||||
|| arg.type.isOnlyMetricType())) {
|
||||
throw new AnalysisException(fnName.getFunction() + " requires a numeric parameter: " + this.toSql());
|
||||
}
|
||||
// DecimalV3 scale lower than DEFAULT_MIN_AVG_DECIMAL128_SCALE should do cast
|
||||
|
||||
@ -1663,8 +1663,7 @@ public class FunctionSet<T> {
|
||||
// retention vectorization
|
||||
addBuiltin(AggregateFunction.createBuiltin(FunctionSet.RETENTION,
|
||||
Lists.newArrayList(Type.BOOLEAN),
|
||||
// Type.BOOLEAN will return non-numeric results so we use Type.TINYINT
|
||||
new ArrayType(Type.TINYINT),
|
||||
new ArrayType(Type.BOOLEAN),
|
||||
Type.VARCHAR,
|
||||
true,
|
||||
"",
|
||||
@ -2458,6 +2457,13 @@ public class FunctionSet<T> {
|
||||
null, false, true, false));
|
||||
|
||||
// vectorized
|
||||
addBuiltin(AggregateFunction.createBuiltin(name,
|
||||
Lists.<Type>newArrayList(Type.BOOLEAN), Type.BIGINT, Type.BIGINT, initNull,
|
||||
"",
|
||||
"",
|
||||
null, null,
|
||||
"",
|
||||
null, false, true, false, true));
|
||||
addBuiltin(AggregateFunction.createBuiltin(name,
|
||||
Lists.<Type>newArrayList(Type.TINYINT), Type.BIGINT, Type.BIGINT, initNull,
|
||||
prefix + "3sumIN9doris_udf9BigIntValES3_EEvPNS2_15FunctionContextERKT_PT0_",
|
||||
@ -2913,6 +2919,10 @@ public class FunctionSet<T> {
|
||||
false, true, false));
|
||||
|
||||
// vectorized avg
|
||||
addBuiltin(AggregateFunction.createBuiltin("avg",
|
||||
Lists.<Type>newArrayList(Type.BOOLEAN), Type.DOUBLE, Type.TINYINT,
|
||||
"", "", "", "", "", "", "",
|
||||
false, true, false, true));
|
||||
addBuiltin(AggregateFunction.createBuiltin("avg",
|
||||
Lists.<Type>newArrayList(Type.TINYINT), Type.DOUBLE, Type.TINYINT,
|
||||
"", "", "", "", "", "", "",
|
||||
|
||||
@ -25,7 +25,6 @@ import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSi
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.ArrayType;
|
||||
import org.apache.doris.nereids.types.BooleanType;
|
||||
import org.apache.doris.nereids.types.TinyIntType;
|
||||
import org.apache.doris.nereids.util.ExpressionUtils;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
@ -40,7 +39,7 @@ public class Retention extends AggregateFunction
|
||||
implements ExplicitlyCastableSignature, AlwaysNotNullable {
|
||||
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(ArrayType.of(TinyIntType.INSTANCE)).varArgs(BooleanType.INSTANCE)
|
||||
FunctionSignature.ret(ArrayType.of(BooleanType.INSTANCE)).varArgs(BooleanType.INSTANCE)
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user