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

Yongzhi Chen commented on HIVE-11973:
-------------------------------------

[~xuefuz], the equal one has this stacktrace, it uses 
getCommonClassForComparison if need convert:

FunctionRegistry.implicitConvertible(PrimitiveObjectInspector$PrimitiveCategory,
 PrimitiveObjectInspector$PrimitiveCategory) line: 890  
FunctionRegistry.getCommonClassForComparison(TypeInfo, TypeInfo) line: 763      
GenericUDFOPEqual(GenericUDFBaseCompare).initialize(ObjectInspector[]) line: 
138        
GenericUDFOPEqual(GenericUDF).initializeAndFoldConstants(ObjectInspector[]) 
line: 139   
ExprNodeGenericFuncDesc.newInstance(GenericUDF, String, List<ExprNodeDesc>) 
line: 234   
TypeCheckProcFactory$DefaultExprProcessor.getXpathOrFuncExprNodeDesc(ASTNode, 
boolean, ArrayList<ExprNodeDesc>, TypeCheckCtx) line: 1082        
TypeCheckProcFactory$DefaultExprProcessor.process(Node, Stack<Node>, 
NodeProcessorCtx, Object...) line: 1301    
DefaultRuleDispatcher.dispatch(Node, Stack<Node>, Object...) line: 90   

The logic of getCommonClassForComparison very similar to 
getCommonClassForUnionAll.

What I am trying to say in the previous comment is: When only consider type 
conversion, x will need compare each value, that means it can unionall with 
each value too. The ReturnObjectInspectorResolver.update is just to find out 
which type will be used for the conversion that x can compare with each value 
in the set. 

> IN operator fails when the column type is DATE 
> -----------------------------------------------
>
>                 Key: HIVE-11973
>                 URL: https://issues.apache.org/jira/browse/HIVE-11973
>             Project: Hive
>          Issue Type: Bug
>          Components: Query Processor
>    Affects Versions: 1.0.0
>            Reporter: sanjiv singh
>            Assignee: Yongzhi Chen
>         Attachments: HIVE-11973.1.patch, HIVE-11973.2.patch
>
>
> Test DLL :
> {code}
> CREATE TABLE `date_dim`(
>   `d_date_sk` int, 
>   `d_date_id` string, 
>   `d_date` date, 
>   `d_current_week` string, 
>   `d_current_month` string, 
>   `d_current_quarter` string, 
>   `d_current_year` string) ;
> {code}
> Hive query :
> {code}
>     SELECT *  
>     FROM   date_dim     
>     WHERE d_date  IN ('2000-03-22','2001-03-22')  ;
> {code}
> In 1.0.0 ,  the above query fails with:
> {code}
>     FAILED: SemanticException [Error 10014]: Line 1:180 Wrong arguments 
> ''2001-03-22'': The arguments for IN should be the same type! Types are: 
> {date IN (string, string)}
> {code}
> I changed the query as given to pass the error :
> {code}
>     SELECT *  
>     FROM   date_dim     
>     WHERE d_date  IN (CAST('2000-03-22' AS DATE) , CAST('2001-03-22' AS DATE) 
>  )  ;
> {code}
> But it works without casting  :
> {code}
>     SELECT *  
>     FROM   date_dim     
>     WHERE d_date   = '2000-03-22' ;
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to