Skip to content

Commit

Permalink
fix fe of regr_slope and add test_regr_slope.groovy
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoruet committed Sep 27, 2024
1 parent 40b3f80 commit 13d4676
Show file tree
Hide file tree
Showing 7 changed files with 339 additions and 209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.window.SupportWindowAnalytic;
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;
Expand All @@ -40,9 +40,8 @@
/**
* AggregateFunction 'regr_slope'.
*/

public class RegrSlope extends NullableAggregateFunction
implements BinaryExpression, ExplicitlyCastableSignature, SupportWindowAnalytic {
public class RegrSlope extends AggregateFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE),
Expand All @@ -57,18 +56,14 @@ public class RegrSlope extends NullableAggregateFunction
* Constructor with 2 arguments.
*/
public RegrSlope(Expression arg1, Expression arg2) {
this(false, true, arg1, arg2);
this(false, arg1, arg2);
}

/**
* Constructor with distinct flag and 2 arguments.
*/
public RegrSlope(boolean distinct, Expression arg1, Expression arg2) {
this(distinct, true, arg1, arg2);
}

public RegrSlope(boolean distinct, boolean alwaysNullable, Expression arg1, Expression arg2) {
super("regr_slope", distinct, alwaysNullable, arg1, arg2);
super("regr_slope", distinct, arg1, arg2);
}

@Override
Expand All @@ -87,17 +82,12 @@ public void checkLegalityBeforeTypeCoercion() throws AnalysisException {
@Override
public RegrSlope withDistinctAndChildren(boolean distinct, List<Expression> children) {
Preconditions.checkArgument(children.size() == 2);
return new RegrSlope(distinct, alwaysNullable, children.get(0), children.get(1));
}

@Override
public NullableAggregateFunction withAlwaysNullable(boolean alwaysNullable) {
return new RegrSlope(distinct, alwaysNullable, children().get(0), children().get(1));
return new RegrSlope(distinct, children.get(0), children.get(1));
}

@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitNullableAggregateFunction(this, context);
return visitor.visitRegrSlope(this, context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ default R visitRegrIntercept(RegrIntercept regrIntercept, C context) {
}

default R visitRegrSlope(RegrSlope regrSlope, C context) {
return visitNullableAggregateFunction(regrSlope, context);
return visitAggregateFunction(regrSlope, context);
}

default R visitRetention(Retention retention, C context) {
Expand Down

This file was deleted.

This file was deleted.

114 changes: 114 additions & 0 deletions regression-test/data/query_p0/aggregate/test_regr_slope.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql_empty_1 --
\N

-- !sql_empty_2 --

-- !sql_int_1 --
0.0

-- !sql_int_2 --
\N

-- !sql_int_3 --
0.6853448275862069

-- !sql_int_4 --
0.6853448275862069

-- !sql_int_5 --
0.6853448275862069

-- !sql_int_6 --
0.0

-- !sql_int_7 --
\N

-- !sql_int_8 --
0.7390029325513197

-- !sql_int_8 --
\N
\N
9.0
\N
\N

-- !sql_int_9 --
0.7401574803149606

-- !sql_int_9 --
9.0
\N
\N

-- !sql_int_10 --
0.7401574803149606

-- !sql_int_10 --
9.0
\N
\N

-- !sql_double_1 --
0.0

-- !sql_double_2 --
\N

-- !sql_double_3 --
0.6987176230207431

-- !sql_double_3 --
\N
\N
\N
\N
\N

-- !sql_double_4 --
0.6987176230207446

-- !sql_double_4 --
\N
\N
\N
\N
\N

-- !sql_double_5 --
0.6987176230207446

-- !sql_double_6 --
0.0

-- !sql_double_7 --
\N

-- !sql_double_8 --
0.7390029325513197

-- !sql_double_8 --
\N
\N
9.0
\N
\N

-- !sql_double_9 --
0.7401574803149606

-- !sql_double_9 --
9.0
\N
\N

-- !sql_double_10 --
0.7401574803149606

-- !sql_double_10 --
9.0
\N
\N

This file was deleted.

Loading

0 comments on commit 13d4676

Please sign in to comment.