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

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new ab879d4d1d8 [chore](float) Unify floating number to string (#66375)
ab879d4d1d8 is described below

commit ab879d4d1d80387b27afb756719d654b99f48361
Author: TengJianPing <[email protected]>
AuthorDate: Tue Aug 4 09:51:10 2026 +0800

    [chore](float) Unify floating number to string (#66375)
    
    ### What problem does this PR solve?
    
    Issue Number: close #xxx
    
    Related PR: #65302
    
    Problem Summary:
    
    Floating number to string is now handled correctly by
    CastToString::from_number in PR
    https://github.com/apache/doris/pull/65609, special handing in
    DataTypeNumberSerDe<T>::to_olap_string is not necessary now.
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test <!-- At least one of them must be included. -->
        - [ ] Regression test
        - [ ] Unit Test
        - [ ] Manual test (add detailed scripts or steps below)
        - [ ] No need to test or manual test. Explain why:
    - [ ] This is a refactor/code format and no logic has been changed.
            - [ ] Previous test can cover this change.
            - [ ] No code files have been changed.
            - [ ] Other reason <!-- Add your reason?  -->
    
    - Behavior changed:
        - [ ] No.
        - [ ] Yes. <!-- Explain the behavior change -->
    
    - Does this need documentation?
        - [ ] No.
    - [ ] Yes. <!-- Add document PR link here. eg:
    https://github.com/apache/doris-website/pull/1214 -->
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label <!-- Add branch pick label that this PR
    should merge into -->
---
 be/src/core/data_type_serde/data_type_number_serde.cpp     | 14 +++-----------
 .../test_aggregate_percentile_approx_array.out             |  2 +-
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/be/src/core/data_type_serde/data_type_number_serde.cpp 
b/be/src/core/data_type_serde/data_type_number_serde.cpp
index 72fcad1a650..df9ccb529da 100644
--- a/be/src/core/data_type_serde/data_type_number_serde.cpp
+++ b/be/src/core/data_type_serde/data_type_number_serde.cpp
@@ -1409,18 +1409,10 @@ std::string 
DataTypeNumberSerDe<T>::to_olap_string(const Field& field) const {
         char buf[8] = {'\0'};
         snprintf(buf, sizeof(buf), "%d", field.get<T>());
         return std::string(buf);
-    } else if constexpr (T == TYPE_FLOAT || T == TYPE_DOUBLE) {
-        auto v = field.get<T>();
-        // inf/nan are stored as zone-map flags, not in min/max strings; route 
them
-        // through CastToString to keep the "Infinity"/"NaN" spelling used 
elsewhere.
-        if (std::isinf(v) || std::isnan(v)) {
-            return CastToString::from_number(v);
-        }
-        // CastToString uses digits10 + 1 significant digits, which may lose 
precision.
-        // ZoneMap bounds must round-trip exactly, so use fmt's shortest 
round-trippable form.
-        return fmt::format("{}", v);
     } else if constexpr (T == TYPE_TINYINT || T == TYPE_SMALLINT || T == 
TYPE_INT ||
-                         T == TYPE_BIGINT) {
+                         T == TYPE_BIGINT || T == TYPE_FLOAT || T == 
TYPE_DOUBLE) {
+        // Floating number to string is now handled correctly by 
CastToString::from_number
+        // in PR https://github.com/apache/doris/pull/65609, special handing 
here is not necessary now.
         return CastToString::from_number(field.get<T>());
     } else if constexpr (T == TYPE_LARGEINT) {
         auto value = field.get<T>();
diff --git 
a/regression-test/data/query_p0/sql_functions/aggregate_functions/test_aggregate_percentile_approx_array.out
 
b/regression-test/data/query_p0/sql_functions/aggregate_functions/test_aggregate_percentile_approx_array.out
index 24c27e94901..87afd8bce24 100644
--- 
a/regression-test/data/query_p0/sql_functions/aggregate_functions/test_aggregate_percentile_approx_array.out
+++ 
b/regression-test/data/query_p0/sql_functions/aggregate_functions/test_aggregate_percentile_approx_array.out
@@ -6,7 +6,7 @@
 [2.25, 10, 27.5]
 
 -- !percentile_approx_array_3 --
-[85.99997711181641, 1.200000047683716, 10, 10]
+[85.9999771118164, 1.2000000476837158, 10, 10]
 
 -- !percentile_approx_array_4 --
 [2.25, 10, 27.5]       [2.25, 10, 27.5]


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

Reply via email to