linrrzqqq opened a new pull request, #63954:
URL: https://github.com/apache/doris/pull/63954
Problem Summary:
`signbit` in Nereids FE constant folding used `value < 0` to determine the
sign, which treats `-0.0` as non-negative and folds it to `false`. This is
inconsistent with:
- the runtime BE implementation, which uses `std::signbit`
- the documented `signbit` behavior, which distinguishes `+0.0` and `-0.0`
`+0.0` and `-0.0` compare equal numerically, so `value < 0` cannot
distinguish them. Their difference is only recorded in the floating-point sign
bit. Using raw bits makes FE constant folding consistent with BE runtime
semantics.
before:
```text
Doris> set debug_skip_fold_constant=true;
Query OK, 0 rows affected (0.024 sec)
Doris> select signbit(cast('+0.0' as double)) , signbit(cast('-0.0' as
double));
+---------------------------------+---------------------------------+
| signbit(cast('+0.0' as double)) | signbit(cast('-0.0' as double)) |
+---------------------------------+---------------------------------+
| 0 | 1 |
+---------------------------------+---------------------------------+
1 row in set (0.108 sec)
Doris> set debug_skip_fold_constant=false;
Query OK, 0 rows affected (0.002 sec)
Doris> select signbit(cast('+0.0' as double)) , signbit(cast('-0.0' as
double));
+---------------------------------+---------------------------------+
| signbit(cast('+0.0' as double)) | signbit(cast('-0.0' as double)) |
+---------------------------------+---------------------------------+
| 0 | 0 |
+---------------------------------+---------------------------------+
```
now:
```text
Doris> set debug_skip_fold_constant=true;
Query OK, 0 rows affected (0.012 sec)
Doris> select signbit(cast('+0.0' as double)) , signbit(cast('-0.0' as
double));
+---------------------------------+---------------------------------+
| signbit(cast('+0.0' as double)) | signbit(cast('-0.0' as double)) |
+---------------------------------+---------------------------------+
| 0 | 1 |
+---------------------------------+---------------------------------+
1 row in set (0.070 sec)
Doris> set debug_skip_fold_constant=false;
Query OK, 0 rows affected (0.002 sec)
Doris> select signbit(cast('+0.0' as double)) , signbit(cast('-0.0' as
double));
+---------------------------------+---------------------------------+
| signbit(cast('+0.0' as double)) | signbit(cast('-0.0' as double)) |
+---------------------------------+---------------------------------+
| 0 | 1 |
+---------------------------------+---------------------------------+
1 row in set (0.010 sec)
```
--
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]