qzsee opened a new pull request, #63092:
URL: https://github.com/apache/doris/pull/63092

   ### What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Example: COALESCE(same_department_income_amount, 0) ==> outputs NULL (where 
same_department_income_amount is of type double).
   
   When assigning the value to the result column in the computation, the 
assignment is done unconditionally (forced), as in:
   
   ```cpp
   result_raw_data[row] +=
                       column_raw_data[row] *
                       typename ColumnType::value_type(!(null_map_data[row] | 
filled_flag[row]));
   ```
   If the argument column column_raw_data's null_map[row] is 1, then the value 
stored in column_raw_data[row] is garbage data. This garbage may contain values 
such as NaN. If a preceding argument of COALESCE happens to be assigned NaN, 
then during subsequent assignments we run into cases like:
   
   0 * NaN = NaN
   num + NaN = NaN
   
   so the assigned result also becomes NaN, which causes value pollution.
   
   By rights the final output should also be NaN, but what is actually returned 
is NULL. The reason is that during result serialization/output, NaN values are 
emitted as NULL.
   
   ```cpp
   tatus DataTypeNumberSerDe<T>::_write_column_to_mysql(const IColumn& column,
                                                         
MysqlRowBuffer<is_binary_format>& result,
                                                         int row_idx, bool 
col_const,
                                                         const FormatOptions& 
options) const {
       //...
       else if constexpr (std::is_same_v<T, float>) {
           if (std::isnan(data[col_index])) {
               // Handle NaN for float, we should push null value
               buf_ret = result.push_null();
           } else {
               buf_ret = result.push_float(data[col_index]);
           }
       } 
     //...
   }
   ```
   
   Related PR: #xxx
   
   Problem Summary:
   
   ### 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 -->
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to