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

luoyuxia commented on FLINK-30559:
----------------------------------

I found the following generated code in Cal Node
{code:java}
// --- Start code generated by 
org.apache.flink.table.planner.codegen.calls.IfCallGen
          isNull$10 = false;
          if (!isNull$10) {
          if (((org.apache.flink.table.data.binary.BinaryStringData) 
str$6).numChars() > 2) {
          result$11 = ((org.apache.flink.table.data.binary.BinaryStringData) 
str$6).substring(0, 2);
          } else {
          if (((org.apache.flink.table.data.binary.BinaryStringData) 
str$6).numChars() < 2) {
          int padLength$12;
          padLength$12 = 2 - 
((org.apache.flink.table.data.binary.BinaryStringData) str$6).numChars();
          org.apache.flink.table.data.binary.BinaryStringData padString$13;
          padString$13 = 
org.apache.flink.table.data.binary.BinaryStringData.blankString(padLength$12);
          result$11 = 
org.apache.flink.table.data.binary.BinaryStringDataUtil.concat(((org.apache.flink.table.data.binary.BinaryStringData)
 str$6), padString$13);
          } else {
          result$11 = ((org.apache.flink.table.data.binary.BinaryStringData) 
str$6);
          }
{code}
I found the code contains the code of substring, it's a bit of weird Seems 
there's some issue in here.

> May get wrong result for `if` expression if it's string data type
> -----------------------------------------------------------------
>
>                 Key: FLINK-30559
>                 URL: https://issues.apache.org/jira/browse/FLINK-30559
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / API
>            Reporter: luoyuxia
>            Priority: Major
>
> Can be reproduced by the folowing code in 
> `org.apache.flink.table.planner.runtime.batch.sql.CalcITCase`
>  
> {code:java}
> checkResult("SELECT if(b > 10, 'ua', c) from Table3", data3) {code}
> The actual result is [co, He, He, ...].
> Seems it will only get the first two characters.
>  



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

Reply via email to