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

   # Proposed changes
   
   before
   ```
   mysql [test]>select cast(1 as DECIMALV3(16, 2)) /  cast(3 as DECIMALV3(16, 
2));
   +-----------------------------------------------------------+
   | CAST(1 AS DECIMALV3(16, 2)) / CAST(3 AS DECIMALV3(16, 2)) |
   +-----------------------------------------------------------+
   |                                                      0.00 |
   +-----------------------------------------------------------+
   
   
   mysql [test]>select * from divtest;
   +------+------+
   | id   | val  |
   +------+------+
   |    3 | 5.00 |
   |    2 | 4.00 |
   |    1 | 3.00 |
   +------+------+
   
   mysql [test]>select cast(1 as decimalv3(16,2)) / val from divtest;
   +-------------------------------------+
   | CAST(1 AS DECIMALV3(16, 2)) / `val` |
   +-------------------------------------+
   |                                   0 |
   |                                   0 |
   |                                   0 |
   +-------------------------------------+
   ```
   
   after
   ```
   mysql [test]>select cast(1 as DECIMALV3(16, 2)) /  cast(3 as DECIMALV3(16, 
2));
   +-----------------------------------------------------------+
   | CAST(1 AS DECIMALV3(16, 2)) / CAST(3 AS DECIMALV3(16, 2)) |
   +-----------------------------------------------------------+
   |                                                      0.33 |
   +-----------------------------------------------------------+
   
   mysql [test]>select cast(1 as decimalv3(16,2)) / val from divtest;
   +-------------------------------------+
   | CAST(1 AS DECIMALV3(16, 2)) / `val` |
   +-------------------------------------+
   |                            0.250000 |
   |                            0.200000 |
   |                            0.333333 |
   +-------------------------------------+
   ```
   This is because in the previous code, the constant 1.000 would be 
transformed into 1.
   
   Therefore, an additional check is added here. If the constant is converted 
through casting, "ReduceType" should not be applied.
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   * [ ] Does it affect the original behavior
   * [ ] Has unit tests been added
   * [ ] Has document been added or modified
   * [ ] Does it need to update dependencies
   * [ ] Is this PR support rollback (If NO, please explain WHY)
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at 
[[email protected]](mailto:[email protected]) by explaining why you 
chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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