This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new ea758e432b6 branch-3.0: [fix](nereids) when 
ColumnStatistics.avgSizeByte is NaN, use default size 1. #54150 (#54272)
ea758e432b6 is described below

commit ea758e432b66e519f8a5a9903be4d2ed2d1530c2
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Aug 14 12:04:49 2025 +0800

    branch-3.0: [fix](nereids) when ColumnStatistics.avgSizeByte is NaN, use 
default size 1. #54150 (#54272)
    
    Cherry-picked from #54150
    
    Co-authored-by: minghong <[email protected]>
---
 .../org/apache/doris/statistics/Statistics.java    |  6 ++-
 .../apache/doris/statistics/StatisticsTest.java    | 53 ++++++++++++++++++++++
 2 files changed, 58 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/statistics/Statistics.java 
b/fe/fe-core/src/main/java/org/apache/doris/statistics/Statistics.java
index 20da97df020..858810a9013 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/statistics/Statistics.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/Statistics.java
@@ -167,7 +167,11 @@ public class Statistics {
             for (Slot slot : slots) {
                 ColumnStatistic s = expressionToColumnStats.get(slot);
                 if (s != null) {
-                    tempSize += Math.max(1, 
Math.min(CharacterType.DEFAULT_WIDTH, s.avgSizeByte));
+                    double avgSize = s.avgSizeByte;
+                    if (!Double.isFinite(avgSize)) {
+                        avgSize = 1;
+                    }
+                    tempSize += Math.max(1, 
Math.min(CharacterType.DEFAULT_WIDTH, avgSize));
                 }
             }
             tupleSize = Math.max(1, tempSize);
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsTest.java
new file mode 100644
index 00000000000..d6519aaed56
--- /dev/null
+++ b/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsTest.java
@@ -0,0 +1,53 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.statistics;
+
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.types.IntegerType;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class StatisticsTest {
+    @Test
+    public void testAvgSizeAbnormal() {
+        SlotReference slot = SlotReference.of("a", IntegerType.INSTANCE);
+        ColumnStatisticBuilder colBuilder = new ColumnStatisticBuilder();
+        colBuilder.setAvgSizeByte(Double.NaN);
+        Statistics stats = new Statistics(1, 1, ImmutableMap.of(slot, 
colBuilder.build()));
+        double tupleSize = stats.computeTupleSize(ImmutableList.of(slot));
+        Assertions.assertEquals(1, tupleSize);
+
+        colBuilder.setAvgSizeByte(Double.POSITIVE_INFINITY);
+        stats = new Statistics(1, 1, ImmutableMap.of(slot, 
colBuilder.build()));
+        tupleSize = stats.computeTupleSize(ImmutableList.of(slot));
+        Assertions.assertEquals(1, tupleSize);
+
+        colBuilder.setAvgSizeByte(Double.NEGATIVE_INFINITY);
+        stats = new Statistics(1, 1, ImmutableMap.of(slot, 
colBuilder.build()));
+        tupleSize = stats.computeTupleSize(ImmutableList.of(slot));
+        Assertions.assertEquals(1, tupleSize);
+
+        colBuilder.setAvgSizeByte(-1.0);
+        stats = new Statistics(1, 1, ImmutableMap.of(slot, 
colBuilder.build()));
+        tupleSize = stats.computeTupleSize(ImmutableList.of(slot));
+        Assertions.assertEquals(1, tupleSize);
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to