[ 
https://issues.apache.org/jira/browse/CALCITE-4888?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jing Zhang updated CALCITE-4888:
--------------------------------
    Description: 
There exists some inconsistency to infer type of Sarg RexLiteral.

The method `RexSargBuilder#getType` in `RexSimplify` using 
`rexBuilder.typeFactory.leastRestrictive(Util.distinctList(types));`

However, The methods `RexBuilder#makeIn` and `RexBuilder#makeBetween` using 
type of first ranges as Sarg RexLiteral's type.

It's better to unify 

when call `RelBuilder.in` to create an `IN` predicate with a list of varchar 
literals which have different length, generated `RexNode` are expected.

for example, ranges parameters are `b.literal("CLERK")` and  `b.literal("A")`

Generated `RexNode` seems to be unexpected because it would cast 'A' to char(5).

  was:
when call `RelBuilder.in` to create an `IN` predicate with a list of varchar 
literals which have different length, generated `RexNode` are expected.

for example, ranges parameters are `b.literal("CLERK")` and  `b.literal("A")`

Generated `RexNode` seems to be unexpected because it would cast 'A' to char(5).


> Unify type inferring logical for Sarg RexLiteral
> ------------------------------------------------
>
>                 Key: CALCITE-4888
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4888
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Jing Zhang
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: image-2021-11-23-10-31-05-137.png
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> There exists some inconsistency to infer type of Sarg RexLiteral.
> The method `RexSargBuilder#getType` in `RexSimplify` using 
> `rexBuilder.typeFactory.leastRestrictive(Util.distinctList(types));`
> However, The methods `RexBuilder#makeIn` and `RexBuilder#makeBetween` using 
> type of first ranges as Sarg RexLiteral's type.
> It's better to unify 
> when call `RelBuilder.in` to create an `IN` predicate with a list of varchar 
> literals which have different length, generated `RexNode` are expected.
> for example, ranges parameters are `b.literal("CLERK")` and  `b.literal("A")`
> Generated `RexNode` seems to be unexpected because it would cast 'A' to 
> char(5).



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to