[Bug](fix) fix the percentile func result do not equal the percentile array rewrite result (#49379)
cherry pick https://github.com/apache/doris/pull/49351
This commit is contained in:
@ -131,7 +131,7 @@ public class BuiltinAggregateFunctions implements FunctionHelper {
|
||||
agg(OrthogonalBitmapIntersect.class, "orthogonal_bitmap_intersect"),
|
||||
agg(OrthogonalBitmapIntersectCount.class, "orthogonal_bitmap_intersect_count"),
|
||||
agg(OrthogonalBitmapUnionCount.class, "orthogonal_bitmap_union_count"),
|
||||
agg(Percentile.class, "percentile"),
|
||||
agg(Percentile.class, "percentile", "percentile_cont"),
|
||||
agg(PercentileApprox.class, "percentile_approx"),
|
||||
agg(PercentileArray.class, "percentile_array"),
|
||||
agg(QuantileUnion.class, "quantile_union"),
|
||||
|
||||
@ -1430,6 +1430,15 @@ public class FunctionSet<T> {
|
||||
"",
|
||||
false, true, false, true));
|
||||
|
||||
addBuiltin(AggregateFunction.createBuiltin("percentile_cont",
|
||||
Lists.newArrayList(Type.BIGINT, Type.DOUBLE), Type.DOUBLE, Type.VARCHAR,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
false, true, false, true));
|
||||
|
||||
addBuiltin(AggregateFunction.createBuiltin("percentile_approx",
|
||||
Lists.<Type>newArrayList(Type.DOUBLE, Type.DOUBLE), Type.DOUBLE, Type.VARCHAR,
|
||||
"",
|
||||
|
||||
@ -25,6 +25,11 @@ import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.BigIntType;
|
||||
import org.apache.doris.nereids.types.DoubleType;
|
||||
import org.apache.doris.nereids.types.FloatType;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
import org.apache.doris.nereids.types.LargeIntType;
|
||||
import org.apache.doris.nereids.types.SmallIntType;
|
||||
import org.apache.doris.nereids.types.TinyIntType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -38,7 +43,13 @@ public class Percentile extends NullableAggregateFunction
|
||||
implements BinaryExpression, ExplicitlyCastableSignature {
|
||||
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(DoubleType.INSTANCE).args(BigIntType.INSTANCE, DoubleType.INSTANCE)
|
||||
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE),
|
||||
FunctionSignature.ret(DoubleType.INSTANCE).args(FloatType.INSTANCE, DoubleType.INSTANCE),
|
||||
FunctionSignature.ret(DoubleType.INSTANCE).args(LargeIntType.INSTANCE, DoubleType.INSTANCE),
|
||||
FunctionSignature.ret(DoubleType.INSTANCE).args(BigIntType.INSTANCE, DoubleType.INSTANCE),
|
||||
FunctionSignature.ret(DoubleType.INSTANCE).args(IntegerType.INSTANCE, DoubleType.INSTANCE),
|
||||
FunctionSignature.ret(DoubleType.INSTANCE).args(SmallIntType.INSTANCE, DoubleType.INSTANCE),
|
||||
FunctionSignature.ret(DoubleType.INSTANCE).args(TinyIntType.INSTANCE, DoubleType.INSTANCE)
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@ -26,6 +26,11 @@ import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.ArrayType;
|
||||
import org.apache.doris.nereids.types.BigIntType;
|
||||
import org.apache.doris.nereids.types.DoubleType;
|
||||
import org.apache.doris.nereids.types.FloatType;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
import org.apache.doris.nereids.types.LargeIntType;
|
||||
import org.apache.doris.nereids.types.SmallIntType;
|
||||
import org.apache.doris.nereids.types.TinyIntType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -40,8 +45,19 @@ public class PercentileArray extends AggregateFunction
|
||||
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(ArrayType.of(DoubleType.INSTANCE))
|
||||
.args(BigIntType.INSTANCE, ArrayType.of(DoubleType.INSTANCE))
|
||||
);
|
||||
.args(DoubleType.INSTANCE, ArrayType.of(DoubleType.INSTANCE)),
|
||||
FunctionSignature.ret(ArrayType.of(DoubleType.INSTANCE))
|
||||
.args(FloatType.INSTANCE, ArrayType.of(DoubleType.INSTANCE)),
|
||||
FunctionSignature.ret(ArrayType.of(DoubleType.INSTANCE))
|
||||
.args(LargeIntType.INSTANCE, ArrayType.of(DoubleType.INSTANCE)),
|
||||
FunctionSignature.ret(ArrayType.of(DoubleType.INSTANCE))
|
||||
.args(BigIntType.INSTANCE, ArrayType.of(DoubleType.INSTANCE)),
|
||||
FunctionSignature.ret(ArrayType.of(DoubleType.INSTANCE))
|
||||
.args(IntegerType.INSTANCE, ArrayType.of(DoubleType.INSTANCE)),
|
||||
FunctionSignature.ret(ArrayType.of(DoubleType.INSTANCE))
|
||||
.args(SmallIntType.INSTANCE, ArrayType.of(DoubleType.INSTANCE)),
|
||||
FunctionSignature.ret(ArrayType.of(DoubleType.INSTANCE))
|
||||
.args(TinyIntType.INSTANCE, ArrayType.of(DoubleType.INSTANCE)));
|
||||
|
||||
/**
|
||||
* constructor with 2 arguments.
|
||||
|
||||
@ -182,6 +182,7 @@ public class GenerateFunction {
|
||||
.put("any", "any_value")
|
||||
.put("char_length", "character_length")
|
||||
.put("stddev_pop", "stddev")
|
||||
.put("percentile_cont", "percentile")
|
||||
.put("var_pop", "variance")
|
||||
.put("variance_pop", "variance")
|
||||
.put("var_samp", "variance_samp")
|
||||
|
||||
Reference in New Issue
Block a user