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

   ## Proposed changes
   
   Issue Number: close #xxx
   
   RewriteInPredicateRule may cast InPredicate expr's two child to the same 
type, for example: where cast(age as char) in ('11'), the type of age is int, 
RewriteInPredicateRule will cast expr's two child type to int. As in the 
example above, child 0 will be such struct: 
   ```
   child 0: type: int
   |---  child: type : char
      |-- child: type : int
   ```
   Due to the RewriteInPredicateRule cast the type of the expr to int, it will 
reanalyze stmt, but it will reset stmt first before reanalyze the stmt, and 
reset opt will change child 0 to such struct:
   ````
   child: type : char
       |-- child: type : int
   ```
   It cause two child's type will be cast to varchar in func 
castAllToCompatibleType, the logic of RewriteInPredicateRule will be useless.
   
   In 1.1-lts and 1.2-lts, such case  " where cast(age as char) in ('11')"  
can't work well,  because func castAllToCompatibleType will cast int to char 
but int can't cast to char(master can work well because func 
castAllToCompatibleType will cast int to varchar in such case).
   ```
   MySQL [test]> select user_id from test_cast where cast(age as char) in 
('45');
   ERROR 1105 (HY000): errCode = 2, detailMessage = type not match, 
originType=INT, targeType=CHAR(*)
   ```
   
   ## 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