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

Steve Carlin commented on CALCITE-7287:
---------------------------------------

Sorry, I looked at the code wrong.  5am sleepiness.  This actually didn't work.

In order to make my code work (tested from my database), I need the following 
on line 522:

 rexBuilder.makeLiteral(simplifyLikeString(likeStr, '\\', '%'), 
e.operands.get(1).getType(), true)));

Note that the makeLiteral takes 3 parameters instead of just the one.  This 
forces the makeLIteral to retain the VARCHAR type.

However, I'm not sure this code would work well with the existing code?  If you 
retrained the type from "e.operands", the normal case of CHAR<X> might not be 
what you expect if the string size of parameter 1 changed?  It works fine for 
me because I have a VARCHAR.

> In simplifyLike, the makeLiteral call does not preserve the RelDataType
> -----------------------------------------------------------------------
>
>                 Key: CALCITE-7287
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7287
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.41.0
>            Reporter: Steve Carlin
>            Priority: Major
>              Labels: pull-request-available
>
> In my Calcite code, I have a RexLiteral that is of type RelDataType.VARCHAR 
> (the SqlTypeName is always CHAR)
> However, this information is getting lost in the call here
> [https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L527]
> The result of this simplification gives me a RelDataType.CHAR instead.



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

Reply via email to