doris
doris copied to clipboard
[feature](nereids): SimplifyCastRule
Proposed changes
Issue Number: close #xxx
Problem summary
- Remove redundant cast like
- cast(1 as int) -> 1.
- Merge cast like
- cast(cast(1 as bigint) as string) -> cast(1 as string).
Checklist(Required)
- Does it affect the original behavior:
- [x] Yes
- [ ] No
- [ ] I don't know
- Has unit tests been added:
- [x] Yes
- [ ] No
- [ ] No Need
- Has document been added or modified:
- [ ] Yes
- [ ] No
- [x] No Need
- Does it need to update dependencies:
- [ ] Yes
- [x] No
- Are there any changes that cannot be rolled back:
- [ ] Yes (If Yes, please explain WHY)
- [x] No
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...
The following two casts are not equivalent.
mysql> select cast(cast("1990-09-01 1:00:00" as datetime) as int); +-----------------------------------------------------+ | CAST(CAST('1990-09-01 1:00:00' AS DATETIME) AS INT) | +-----------------------------------------------------+ | -1977439664 | +-----------------------------------------------------+ 1 row in set (0.01 sec)
mysql> select cast("1990-09-01 1:00:00" as int); +-----------------------------------+ | CAST('1990-09-01 1:00:00' AS INT) | +-----------------------------------+ | NULL | +-----------------------------------+ 1 row in set (0.01 sec)
PR approved by at least one committer and no changes requested.
PR approved by anyone and no changes requested.