You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/11/12 04:28:20 UTC

[GitHub] [incubator-doris] EmmyMiao87 opened a new issue #7102: [Feature] Reduce useless cast

EmmyMiao87 opened a new issue #7102:
URL: https://github.com/apache/incubator-doris/issues/7102


   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/incubator-doris/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### Description
   
   Doris 在语义解析的时候,如果发现 Expr 中参数类型无法直接计算,就会增加 cast 逻辑。比如表结构 (k1 int, k2 bigint),对于 Expr  k1=k2 。原始表达式的类型为 k1(int) = k2(bigint) ,直接无法计算,所以需要通过 cast 表达式将 Expr 左孩子类型转成 bigint。则表达式变换成 cast(k1 as bigint) = k2。
   
   ### Use case
   
   在语义解析判断参类型是否兼容的时候,有些类型会增加无用的 cast。
   比如 k1(date) = k2(date) 也会转化为 cast(k1 as datetime) = cast(k2 as datetime)。
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
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 | 正确|
   
   
   
   # 精简代码逻辑
   
   Type.getCmpType(Type t1, Type t2)
   精简为从一个二维数组直接取值。


-- 
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-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 commented on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 commented on issue #7102:
URL: https://github.com/apache/incubator-doris/issues/7102#issuecomment-968508822


   |---|---|---|
   | BetweenPredicate | ||
   


-- 
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-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
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-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
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-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
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 | 
   | --- | --- | --- | 
   | 
   
   
   ## 是否能精简统一各个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-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 edited a comment on issue #7102:
URL: https://github.com/apache/incubator-doris/issues/7102#issuecomment-968508822






-- 
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-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
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-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 edited a comment on issue #7102:
URL: https://github.com/apache/incubator-doris/issues/7102#issuecomment-968508822






-- 
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-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
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 | | |
   | 
   
   
   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: commits-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
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 | 正确|
   
   
   
   ## 精简代码逻辑
   
   Type.getCmpType(Type t1, Type t2)
   精简为从一个二维数组直接取值。


-- 
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-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
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 | | |
   | 
   
   
   ## 规则明细
   Analyzer.castAllToCompatibleType(List<Exprs> exprs) 转化规则
   将所有 Expr 转成一个大家都可兼容的类型
   
   | Type1 | Type2 | CompatibleType | 
   | --- | --- | --- | 
   | 
   
   
   ## 是否能精简统一各个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-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 edited a comment on issue #7102:
URL: https://github.com/apache/incubator-doris/issues/7102#issuecomment-968508822


   Cast 可能发生的位置
   1. 多参表达式,各个参数之间兼容处理。
   
   | Expr | cast 规则|
   |---|---|
   | BetweenPredicate | |
   


-- 
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-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 edited a comment on issue #7102:
URL: https://github.com/apache/incubator-doris/issues/7102#issuecomment-968508822


   Cast 可能发生的位置
   1. 多参表达式,各个参数之间兼容处理。
   
   由于不同的表达式对多参兼容性的处理规则不太相同,所以首先需要整理各个表达式都使用了哪些 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: commits-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
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-unsubscribe@doris.apache.org

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



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


[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #7102: [Feature] Reduce useless cast

Posted by GitBox <gi...@apache.org>.
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-unsubscribe@doris.apache.org

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



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