EmmyMiao87 edited a comment on issue #7102:
URL: 
https://github.com/apache/incubator-doris/issues/7102#issuecomment-968508822


   # 如何梳理所有 Expr 中各个类型转换是否存在无意义的 cast
   1. 梳理各个不同表达式,及对应的cast 规则并记录。
   2. 判断 cast 规则是否合理。
   3. 是否能统一 cast 规则。
   
   ## 梳理
   由于不同的表达式对多参兼容性的处理规则不太相同,所以首先需要整理各个表达式都使用了哪些 cast 规则。
   比如对于 BetweenPredicate 来说,c1 between a and b 。 则需要找到 c1, a, b 三个参数都能兼容的类型。
   ```c1(int) between a (bigint) and b (varchar)``` 则会转化为 ```cast(c1 as 
varchar) between cast(a as varchar) and b(varchar)```
   但对于 BinaryPredicate 来说,a = b 。当 a(int) = b(string) 的时候,他们的兼容类型是 int,则会转化为 
``` a = cast(b as int) ```
   下表为不同表达式,以及他们对应的 cast 规则记录。
   | Expr | cast 规则 | 
   |---|---| ---| 
   | BetweenPredicate | Analyzer.castAllToCompatibleType()| 
   | InPredicate |  | 
   | BinaryPredicate | | 
   
   ### 规则正确性判断
   1. 对照 Mysql 行为,尽量保持一致
   2. 查看 be 函数实现,是否存在该类型的函数。
   3. 那种兼容策略性能更好,比如 int 和 date 对齐方式不同。 
   
   ## 规则明细
   Analyzer.castAllToCompatibleType(List<Exprs> exprs) 转化规则
   将所有 Expr 转成一个大家都可兼容的类型
   
   | Type1 | Type2 | CompatibleType | After swapping left and right | 是否正确或可以优化 
|
   | --- | --- | --- | ---| --- |
   | int | bigint | bigint| bigint | 正确|
   
   
   
   ## 是否能精简统一各个cast 规则


-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to