[ 
https://issues.apache.org/jira/browse/KYLIN-5756?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17830478#comment-17830478
 ] 

pengfei.zhan commented on KYLIN-5756:
-------------------------------------

h1. Root Cause

When the plus operator is used in scalar query, calcite will do constant 
folding, and when calculating the value, it will convert the expression into 
java code, and each plus operator will determine whether it needs to be 
converted into a custom plus function or whether it should be used directly 
with the addition operator in java language.

There are three conditions for the  plus operator were considered as a custom 
plus function: 
1. plus left is not a basic type; 
2. plus right is a bigDecimal type; 
3. (more complex), any one of them can be satisfied, for '1' + 3 + '3', '1' + 3 
is of type double, and '3' is of type string, so the second plus sign does not 
satisfy all three conditions, which results in the expression translated into 
java code as plus('1' + 3) + '3'.

> Concat string and number with '+' gives unexpected result
> ---------------------------------------------------------
>
>                 Key: KYLIN-5756
>                 URL: https://issues.apache.org/jira/browse/KYLIN-5756
>             Project: Kylin
>          Issue Type: Improvement
>          Components: Query Engine
>    Affects Versions: 5.0-beta
>            Reporter: pengfei.zhan
>            Assignee: pengfei.zhan
>            Priority: Major
>             Fix For: 5.0-beta
>
>
> Concat string and number gives unexpected result.
> For example:
> 1. concat constant with plus operator, gives unexpected result
> {code:java}
> 1' + 3 + 3  // 7 (correct)
> '1' + 3 + '3'  // 4.03 (wrong result)
> '1' + '3' + 'a' // error
> {code}
> 2. concat string and number, the first '+' produces null
> {code:java}
> 'q' + 1 + 1 // error
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to