[fix](DECIMAL) error DECIMAL cat to BOOLEAN
Proposed changes
before
mysql []>select 3.14 and 3.0;
+--------------------------------------------------+
| (cast(3.14 as BOOLEAN) AND cast(3.0 as BOOLEAN)) |
+--------------------------------------------------+
| 3 |
+--------------------------------------------------+
mysql [test]>select cast(3.000 as boolean) ;
+------------------------+
| cast(3.000 as BOOLEAN) |
+------------------------+
| 3 |
+------------------------+
now
mysql [test]>select cast(3.000 as boolean) ;
+------------------------+
| cast(3.000 as BOOLEAN) |
+------------------------+
| 1 |
+------------------------+
In the past, casting DECIMAL to BOOLEAN directly converted it to an integer.
Further comments
If this is a relatively large or complex change, kick off the discussion at [email protected] by explaining why you chose the solution you did and what alternatives you considered, etc...
Thank you for your contribution to Apache Doris. Don't know what should be done next? See How to process your PR
Since 2024-03-18, the Document has been moved to doris-website. See Doris Document.
run buildall
clang-tidy review says "All clean, LGTM! :+1:"
TeamCity be ut coverage result: Function Coverage: 35.44% (8921/25174) Line Coverage: 27.14% (73318/270118) Region Coverage: 26.26% (37861/144178) Branch Coverage: 23.07% (19300/83648) Coverage Report: http://coverage.selectdb-in.cc/coverage/e2f4d188fa0eec6fc6d7f7a3a4c3b178d4fc0977_e2f4d188fa0eec6fc6d7f7a3a4c3b178d4fc0977/report/index.html
https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html#function_cast
cast function of mysql do not support using bool as type argument.
clang-tidy review says "All clean, LGTM! :+1:"
https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html#function_cast
cast function of mysql do not support using bool as type argument.
But there is implicit conversion to boolean. https://dbfiddle.uk/FGUsvxTk
run buildall
https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html#function_cast cast function of mysql do not support using bool as type argument.
But there is implicit conversion to boolean. https://dbfiddle.uk/FGUsvxTk
why do you think there is an implicit conversion?
https://dev.mysql.com/doc/refman/8.3/en/logical-operators.html#operator_and
oprator_and checks whether operands are zero or NULL, it has nothing to do with type convert.
https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html#function_cast cast function of mysql do not support using bool as type argument.
But there is implicit conversion to boolean. https://dbfiddle.uk/FGUsvxTk
why do you think there is an implicit conversion?
https://dev.mysql.com/doc/refman/8.3/en/logical-operators.html#operator_and
oprator_and checks whether operands are zero or NULL, it has nothing to do with type convert.
My mistake, as doris implementation involves implicit conversion. But such results in doris
mysql []>set enable_fold_constant_by_be = false;
Query OK, 0 rows affected (0.00 sec)
mysql []>select 3.14 and 3.0;
+--------------------------------------------------+
| (cast(3.14 as BOOLEAN) AND cast(3.0 as BOOLEAN)) |
+--------------------------------------------------+
| 3 |
+--------------------------------------------------+
1 row in set (0.03 sec)
mysql []>desc select 3.14 and 3.0;
+----------------------------------------------------------+
| Explain String(Nereids Planner) |
+----------------------------------------------------------+
| PLAN FRAGMENT 0 |
| OUTPUT EXPRS: |
| (cast(3.14 as BOOLEAN) AND cast(3.0 as BOOLEAN))[#0] |
| PARTITION: UNPARTITIONED |
| |
| HAS_COLO_PLAN_NODE: false |
| |
| VRESULT SINK |
| MYSQL_PROTOCAL |
| |
| 0:VUNION(30) |
| constant exprs: |
| CAST(3.14 AS BOOLEAN) AND CAST(3.0 AS BOOLEAN) |
+----------------------------------------------------------+
13 rows in set (0.01 sec)
mysql []>select 3.14 and 2.0;
+--------------------------------------------------+
| (cast(3.14 as BOOLEAN) AND cast(2.0 as BOOLEAN)) |
+--------------------------------------------------+
| 2 |
+--------------------------------------------------+
https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html#function_cast cast function of mysql do not support using bool as type argument.
But there is implicit conversion to boolean. https://dbfiddle.uk/FGUsvxTk
why do you think there is an implicit conversion? https://dev.mysql.com/doc/refman/8.3/en/logical-operators.html#operator_and oprator_and checks whether operands are zero or NULL, it has nothing to do with type convert.
My mistake, as doris implementation involves implicit conversion. But such results in doris
mysql []>set enable_fold_constant_by_be = false; Query OK, 0 rows affected (0.00 sec) mysql []>select 3.14 and 3.0; +--------------------------------------------------+ | (cast(3.14 as BOOLEAN) AND cast(3.0 as BOOLEAN)) | +--------------------------------------------------+ | 3 | +--------------------------------------------------+ 1 row in set (0.03 sec) mysql []>desc select 3.14 and 3.0; +----------------------------------------------------------+ | Explain String(Nereids Planner) | +----------------------------------------------------------+ | PLAN FRAGMENT 0 | | OUTPUT EXPRS: | | (cast(3.14 as BOOLEAN) AND cast(3.0 as BOOLEAN))[#0] | | PARTITION: UNPARTITIONED | | | | HAS_COLO_PLAN_NODE: false | | | | VRESULT SINK | | MYSQL_PROTOCAL | | | | 0:VUNION(30) | | constant exprs: | | CAST(3.14 AS BOOLEAN) AND CAST(3.0 AS BOOLEAN) | +----------------------------------------------------------+ 13 rows in set (0.01 sec) mysql []>select 3.14 and 2.0; +--------------------------------------------------+ | (cast(3.14 as BOOLEAN) AND cast(2.0 as BOOLEAN)) | +--------------------------------------------------+ | 2 | +--------------------------------------------------+
I think the problem here may be signature of and operator is not correct, it should not use boolean as operator.
TeamCity be ut coverage result: Function Coverage: 35.42% (8922/25189) Line Coverage: 27.15% (73314/270072) Region Coverage: 26.25% (37843/144154) Branch Coverage: 23.08% (19290/83594) Coverage Report: http://coverage.selectdb-in.cc/coverage/e98c42d5c932a31f6568a722ea5995bdd9c2f9f6_e98c42d5c932a31f6568a722ea5995bdd9c2f9f6/report/index.html