EmmyMiao87 edited a comment on issue #7102: URL: https://github.com/apache/incubator-doris/issues/7102#issuecomment-968508822
Cast 发生的位置 1. 多参表达式,各个参数之间兼容处理。 由于不同的表达式对多参兼容性的处理规则不太相同,所以首先需要整理各个表达式都使用了哪些 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 | | Analyzer.castAllToCompatibleType(List<Exprs> exprs) 转化规则 将所有 Expr 转成一个大家都可兼容的类型 | Type1 | Type2 | CompatibleType | | --- | --- | --- | | -- 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]
