Skip to content

Commit be3a585

Browse files
committed
address copilot review
1 parent 64ef0d8 commit be3a585

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

be/src/exprs/aggregate/aggregate_function_entropy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ AggregateFunctionPtr create_aggregate_function_entropy(const std::string& name,
3737
TYPE_BOOLEAN, TYPE_TINYINT, TYPE_SMALLINT, TYPE_INT, TYPE_BIGINT, TYPE_LARGEINT,
3838
TYPE_DECIMAL32, TYPE_DECIMAL64, TYPE_DECIMAL128I, TYPE_DECIMAL256, TYPE_DECIMALV2,
3939
TYPE_FLOAT, TYPE_DOUBLE, TYPE_DATE, TYPE_DATETIME, TYPE_DATEV2, TYPE_DATETIMEV2,
40-
TYPE_TIME, TYPE_TIMEV2, TYPE_TIMESTAMPTZ>::
40+
TYPE_TIME, TYPE_TIMEV2, TYPE_TIMESTAMPTZ, TYPE_IPV4, TYPE_IPV6>::
4141
create<AggregateFunctionEntropy, AggregateFunctionEntropySingleNumericData>(
4242
argument_types, result_is_nullable, attr);
4343
if (res) {

be/test/exprs/aggregate/agg_entropy_test.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,25 @@ TEST_F(AggregateFunctionEntropyTest, test_nullable_entropy) {
102102
// ------------------------------------------------------------
103103
// 5. Empty input test
104104
// ------------------------------------------------------------
105-
TEST_F(AggregateFunctionEntropyTest, test_empty) {
105+
TEST_F(AggregateFunctionEntropyTest, test_empty_1) {
106106
create_agg("entropy", false, {std::make_shared<DataTypeInt32>()},
107107
std::make_shared<DataTypeFloat64>());
108108

109109
Block block = ColumnHelper::create_block<DataTypeInt32>({});
110110

111-
// entropy of empty set = 0
111+
// entropy of non-nullable empty set is 0
112112
execute(block, ColumnHelper::create_column_with_name<DataTypeFloat64>({0.0}));
113113
}
114114

115+
TEST_F(AggregateFunctionEntropyTest, test_empty_2) {
116+
create_agg("entropy", true,
117+
{std::make_shared<DataTypeNullable>(std::make_shared<DataTypeInt32>())},
118+
std::make_shared<DataTypeFloat64>());
119+
120+
Block block = ColumnHelper::create_nullable_block<DataTypeInt32>({}, {});
121+
122+
// entropy of nullable empty set is null
123+
execute(block, ColumnHelper::create_nullable_column_with_name<DataTypeFloat64>({0.0}, {1}));
124+
}
125+
115126
} // namespace doris

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Entropy.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ public Entropy(boolean distinct, Expression arg0, Expression... varArgs) {
4444
}
4545

4646
public Entropy(boolean distinct, boolean alwaysNullable, Expression arg0, Expression... varArgs) {
47-
this(distinct, alwaysNullable, false, ExpressionUtils.mergeArguments(arg0, varArgs));
47+
this(distinct, alwaysNullable, ExpressionUtils.mergeArguments(arg0, varArgs));
4848
}
4949

50-
private Entropy(boolean distinct, boolean alwaysNullable, boolean isSkew, List<Expression> expressions) {
51-
super("entropy", distinct, alwaysNullable, isSkew, expressions);
50+
private Entropy(boolean distinct, boolean alwaysNullable, List<Expression> expressions) {
51+
super("entropy", distinct, alwaysNullable, expressions);
5252
}
5353

5454
private Entropy(NullableAggregateFunctionParams functionParams) {

0 commit comments

Comments
 (0)