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

slim bouguerra commented on CALCITE-2123:
-----------------------------------------

[~julianhyde], thanks for the pointer. Looking at the code I am suspecting that 
issue is how we are invoking {code} 
org.apache.calcite.sql.type.SqlTypeUtil#canCastFrom{code} at the function 
{code} org.apache.calcite.sql.type.SqlTypeFactoryImpl#leastRestrictiveByCast 
{code} TBH am not sure what the boolean var {code} boolean coerce{code} means 
exactly.
Althought i when i change the code to the following (instead of coerce=false 
use true)
{code} 
if (SqlTypeUtil.canCastFrom(type, resultType, true)) {
{code}
we get positive resutl for cast from VarChar to Decimal.
Not sure if that is the actual fix.
am still trying to wrap my mind please let me know if am on the wrong track.

> Bug in the Druid Filter Translation when Comparing String Ref to a Constant 
> Number
> ----------------------------------------------------------------------------------
>
>                 Key: CALCITE-2123
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2123
>             Project: Calcite
>          Issue Type: Bug
>          Components: druid
>            Reporter: slim bouguerra
>            Assignee: Julian Hyde
>
> The following query {code} SELECT COUNT(*) FROM  \"foodmart\"  WHERE 
> \"product_id\" = 16.0{code} Translates to a Druid Table Scan with a String to 
> String Selector comparison filter.
> instead we need to have a Bound filter that cast the String to number.
> This is what we should expect.
> {code} 
> {"type":"bound","dimension":"product_id","lower":"16.0","lowerStrict":false,"upper":"16.0","upperStrict":false,"ordering":"numeric"}
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to