Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.doris.nereids.rules.RuleType;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.functions.agg.AggregateFunction;
import org.apache.doris.nereids.trees.expressions.functions.agg.NullIgnoringAggregateFunction;
import org.apache.doris.nereids.trees.expressions.functions.scalar.If;
import org.apache.doris.nereids.trees.expressions.literal.NullLiteral;
import org.apache.doris.nereids.trees.plans.Plan;
Expand Down Expand Up @@ -57,6 +58,9 @@ public Rule build() {
return null;
}
for (AggregateFunction aggFun : aggFunctions) {
if (!(aggFun instanceof NullIgnoringAggregateFunction)) {
return null;
}
// check whether we only have on case when/if in aggregate function
if (aggFun.getArguments().size() != 1) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* AggregateFunction 'AI_AGG'.
*/
public class AIAgg extends NullableAggregateFunction
implements ExplicitlyCastableSignature, NotSupportAggState {
implements ExplicitlyCastableSignature, NotSupportAggState, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
* AggregateFunction 'any_value'. This class is generated by GenerateFunction.
*/
public class AnyValue extends NullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature, RollUpTrait {
implements UnaryExpression, ExplicitlyCastableSignature, RollUpTrait,
NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.retArgType(0).args(AnyDataType.INSTANCE_WITHOUT_INDEX)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* AggregateFunction 'avg_weighted'. This class is generated by GenerateFunction.
*/
public class AvgWeighted extends NullableAggregateFunction
implements BinaryExpression, ExplicitlyCastableSignature {
implements BinaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* AggregateFunction 'bitmap_agg'.
*/
public class BitmapAgg extends NotNullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature {
implements UnaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE).args(BigIntType.INSTANCE),
FunctionSignature.ret(BitmapType.INSTANCE).args(IntegerType.INSTANCE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
* AggregateFunction 'bitmap_intersect'. This class is generated by GenerateFunction.
*/
public class BitmapIntersect extends NotNullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature, BitmapFunction {
implements UnaryExpression, ExplicitlyCastableSignature, BitmapFunction,
NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE).args(BitmapType.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
* AggregateFunction 'bitmap_union'. This class is generated by GenerateFunction.
*/
public class BitmapUnion extends NotNullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature, BitmapFunction, RollUpTrait {
implements UnaryExpression, ExplicitlyCastableSignature, BitmapFunction, RollUpTrait,
NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE).args(BitmapType.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
* AggregateFunction 'bitmap_union_count'. This class is generated by GenerateFunction.
*/
public class BitmapUnionCount extends NotNullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature, BitmapFunction, RollUpTrait {
implements UnaryExpression, ExplicitlyCastableSignature, BitmapFunction, RollUpTrait,
NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(BitmapType.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* AggregateFunction 'bitmap_union_int'. This class is generated by GenerateFunction.
*/
public class BitmapUnionInt extends NotNullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature {
implements UnaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(SmallIntType.INSTANCE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* AggregateFunction 'bool_and'.
*/
public class BoolAnd extends NullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature {
implements UnaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BooleanType.INSTANCE).args(BooleanType.INSTANCE)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* AggregateFunction 'bool_or'.
*/
public class BoolOr extends NullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature {
implements UnaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {
Comment thread
morrySnow marked this conversation as resolved.
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BooleanType.INSTANCE).args(BooleanType.INSTANCE)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* AggregateFunction 'bool_xor'.
*/
public class BoolXor extends NullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature {
implements UnaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BooleanType.INSTANCE).args(BooleanType.INSTANCE)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* AggregateFunction 'collect_list'. This class is generated by GenerateFunction.
*/
public class CollectList extends NotNullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature {
implements UnaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {
Comment thread
morrySnow marked this conversation as resolved.

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(ArrayType.of(new FollowToAnyDataType(0))).args(new AnyDataType(0)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* AggregateFunction 'collect_set'. This class is generated by GenerateFunction.
*/
public class CollectSet extends NotNullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature {
implements UnaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(ArrayType.of(new FollowToAnyDataType(0))).args(new AnyDataType(0)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* AggregateFunction 'corr'. This class is generated by GenerateFunction.
*/
public class Corr extends NullableAggregateFunction
implements BinaryExpression, ExplicitlyCastableSignature {
implements BinaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* AggregateFunction 'corr_welford'. This class is generated by GenerateFunction.
*/
public class CorrWelford extends NullableAggregateFunction
implements BinaryExpression, ExplicitlyCastableSignature {
implements BinaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* AggregateFunction 'covar'. This class is generated by GenerateFunction.
*/
public class Covar extends NullableAggregateFunction
implements BinaryExpression, ExplicitlyCastableSignature {
implements BinaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* AggregateFunction 'covar_samp'. This class is generated by GenerateFunction.
*/
public class CovarSamp extends NullableAggregateFunction
implements BinaryExpression, ExplicitlyCastableSignature {
implements BinaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@

/** datasketches_hll_union_agg agg function. */
public class DataSketchesHllUnionAgg extends NotNullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature, FunctionTrait, RollUpTrait {
implements UnaryExpression, ExplicitlyCastableSignature, FunctionTrait, RollUpTrait,
NullIgnoringAggregateFunction {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(StringType.INSTANCE),
FunctionSignature.ret(DoubleType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* timestamp columns use {@code intDiv(toUnixTimestamp(ts), interval_seconds)}.
*/
public class ExponentialMovingAverage extends NullableAggregateFunction
implements ExplicitlyCastableSignature {
implements ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* AggregateFunction 'group_array_intersect'.
*/
public class GroupArrayIntersect extends NotNullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature {
implements UnaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.retArgType(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* AggregateFunction 'group_array_union'.
*/
public class GroupArrayUnion extends NotNullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature {
implements UnaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.retArgType(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* AggregateFunction 'group_bit_and'. This class is generated by GenerateFunction.
*/
public class GroupBitAnd extends NullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature {
implements UnaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* AggregateFunction 'group_bit_or'. This class is generated by GenerateFunction.
*/
public class GroupBitOr extends NullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature {
implements UnaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* AggregateFunction 'group_bit_xor'. This class is generated by GenerateFunction.
*/
public class GroupBitXor extends NullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature {
implements UnaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* AggregateFunction 'group_bitmap_xor'. This class is generated by GenerateFunction.
*/
public class GroupBitmapXor extends NullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature {
implements UnaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE).args(BitmapType.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* AggregateFunction 'histogram'. This class is generated by GenerateFunction.
*/
public class Histogram extends NotNullableAggregateFunction
implements ExplicitlyCastableSignature {
implements ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
* AggregateFunction 'hll_union'. This class is generated by GenerateFunction.
*/
public class HllUnion extends NotNullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature, HllFunction, RollUpTrait {
implements UnaryExpression, ExplicitlyCastableSignature, HllFunction, RollUpTrait,
NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(HllType.INSTANCE).args(HllType.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
* AggregateFunction 'hll_union_agg'. This class is generated by GenerateFunction.
*/
public class HllUnionAgg extends NotNullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature, HllFunction, RollUpTrait {
implements UnaryExpression, ExplicitlyCastableSignature, HllFunction, RollUpTrait,
NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(HllType.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* AggregateFunction 'intersect_count'. This class is generated by GenerateFunction.
*/
public class IntersectCount extends NotNullableAggregateFunction
implements ExplicitlyCastableSignature, BitmapIntersectFunction {
implements ExplicitlyCastableSignature, BitmapIntersectFunction, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = DataType.trivialTypes().stream()
.map(type -> FunctionSignature.ret(BigIntType.INSTANCE).varArgs(BitmapType.INSTANCE, type, type))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
* AggregateFunction 'Kurt'.
*/
public class Kurt extends AggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable,
NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
/**
* AggregateFunction 'linear_histogram'.
*/
public class LinearHistogram extends NotNullableAggregateFunction implements ExplicitlyCastableSignature {
public class LinearHistogram extends NotNullableAggregateFunction
implements ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

/** Base class for aggregate functions that aggregate Map values by key. */
public abstract class MapAggregateFunction extends NotNullableAggregateFunction
implements UnaryExpression, CustomSignature {
implements UnaryExpression, CustomSignature, NullIgnoringAggregateFunction {

protected MapAggregateFunction(String name, Expression arg) {
this(name, false, arg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* AggregateFunction 'max_by'. This class is generated by GenerateFunction.
*/
public class MaxBy extends NullableAggregateFunction
implements BinaryExpression, ExplicitlyCastableSignature {
implements BinaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.retArgType(0).args(AnyDataType.INSTANCE_WITHOUT_INDEX, AnyDataType.INSTANCE_WITHOUT_INDEX)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* AggregateFunction 'median'. This class is generated by GenerateFunction.
*/
public class Median extends NullableAggregateFunction
implements UnaryExpression, ExplicitlyCastableSignature {
implements UnaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* AggregateFunction 'min_by'. This class is generated by GenerateFunction.
*/
public class MinBy extends NullableAggregateFunction
implements BinaryExpression, ExplicitlyCastableSignature {
implements BinaryExpression, ExplicitlyCastableSignature, NullIgnoringAggregateFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.retArgType(0).args(AnyDataType.INSTANCE_WITHOUT_INDEX, AnyDataType.INSTANCE_WITHOUT_INDEX)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

/** MultiDistinctCount */
public class MultiDistinctCount extends NotNullableAggregateFunction
implements ExplicitlyCastableSignature, MultiDistinction {
implements ExplicitlyCastableSignature, MultiDistinction, NullIgnoringAggregateFunction {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).varArgs(AnyDataType.INSTANCE_WITHOUT_INDEX)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@

/** MultiDistinctSum */
public class MultiDistinctSum extends NullableAggregateFunction implements UnaryExpression,
ExplicitlyCastableSignature, ComputePrecisionForSum, MultiDistinction, NeedSessionVarGuard {
ExplicitlyCastableSignature, ComputePrecisionForSum, MultiDistinction, NeedSessionVarGuard,
NullIgnoringAggregateFunction {
public MultiDistinctSum(Expression arg0) {
this(false, arg0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@

/** MultiDistinctSum0 */
public class MultiDistinctSum0 extends NotNullableAggregateFunction implements UnaryExpression,
ExplicitlyCastableSignature, ComputePrecisionForSum, MultiDistinction, NeedSessionVarGuard {
ExplicitlyCastableSignature, ComputePrecisionForSum, MultiDistinction, NeedSessionVarGuard,
NullIgnoringAggregateFunction {
public MultiDistinctSum0(Expression arg0) {
this(false, arg0);
}
Expand Down
Loading
Loading