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

Jing Zhang commented on CALCITE-4888:
-------------------------------------

Hi, [~julianhyde], Thanks a lot for explanation.
> whose value is NULL and whose type is DATE.
In this case, RexBuilder would generate a disjunction like "args = point0 or 
args=point1 or ..", it would not generate a Search RexCall by casting null to 
least restrictive type.
The detailed processing steps are as following:
1. before make Search RexCall, RexBuilder would try to convert all input 
expressions to a search argument. 
 !screenshot-3.png! 
2. traverse the list of expressions, convert each expression to comparable value
!screenshot-1.png!
3.  For null value literal or non-literal RexNode, toComparable method would 
return null which leads to toSarg return null
!screenshot-2.png!
4. If search argument is null, RexBuilder would make a disjunction call.

I add test RexBuilderTest.testMakeInWithNullLiteral to cover this case, and add 
test RexBuilderTest.testMakeInWithNonLiteral to validate the generated call is 
a disjunction if there exists a non-literal expression.


> Fix type inferring when call RelBuilder.in with arguments that are different 
> types.
> -----------------------------------------------------------------------------------
>
>                 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, screenshot-1.png, 
> screenshot-2.png, screenshot-3.png
>
>          Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> A problem would occur when people call RelBuilder.in with arguments that are 
> different types.
> If the types of the RelBuilder.in arguments are not compatible (e.g. INTEGER 
> and BOOLEAN, or INTEGER and DATE) then RelBuilder should throw. There should 
> be a test for that.
> If the types are similar but not the same (e.g. INTEGER and SMALLINT or 
> CHAR(5) and CHAR(7)) what should be behavior be? RelBuilder should introduce 
> casts to the least restrictive type.
> Please note that: the update does not directly affect user who are using SQL. 
> It would only effect user who build RelNode or RexNode by RelBuilder.in or 
> RexBuilder.makeIn.



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

Reply via email to