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

Hari Sankar Sivarama Subramaniyan commented on HIVE-7426:
---------------------------------------------------------

One of the reasons I believe that Hive TypeChecking should do stricter job of 
making sure that the input parameters are entered correctly to the fn. In most 
of the cases, the non-vectorized code path does not run into these kind of 
issues since the UDF uses  ObjectInspectorConverters to convert from the source 
object type to the destination object type before performing any operation on 
it where as vectorized code path needs to do this conversion prior to runtime.

About this jira, this looks like an implementation issue with 
GenericUDFBasePad.initialize().     

converter1 = checkArguments(arguments, 0);
    converter2 = checkArguments(arguments, 1);
    converter3 = checkArguments(arguments, 2);

These should be replaced with ObjectInspectorVonverters.getConverter() calls . 
For eg. for the 0th argument , the correct inputOI is checkArguments(arguments, 
0), outputOI is WritableStringObjectInspector.
So the call should be
 converter1 = ObjectInspectorConverters.getConverter(checkArguments(arguments, 
0), WritableStringObjectInspector)

... and so on.

Thanks
Hari

> ClassCastException: ...IntWritable cannot be cast to ...Text involving 
> ql.udf.generic.GenericUDFBasePad.evaluate
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-7426
>                 URL: https://issues.apache.org/jira/browse/HIVE-7426
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Matt McCline
>            Assignee: Matt McCline
>         Attachments: TestWithORC.zip, fail_366.sql, fail_750.sql, fail_856.sql
>
>
> One of several found by Raj Bains.
> M/R or Tez.
> Query does not vectorize, so this is not vector related.
> Query:
> {code}
> SELECT `Calcs`.`datetime0` AS `none_datetime0_ok`,   `Calcs`.`int1` AS 
> `none_int1_ok`,   `Calcs`.`key` AS `none_key_nk`,   CASE WHEN 
> (`Calcs`.`datetime0` IS NOT NULL AND `Calcs`.`int1` IS NOT NULL) THEN 
> FROM_UNIXTIME(UNIX_TIMESTAMP(CONCAT((YEAR(`Calcs`.`datetime0`)+FLOOR((MONTH(`Calcs`.`datetime0`)+`Calcs`.`int1`)/12)),
>  CONCAT('-', CONCAT(LPAD(PMOD(MONTH(`Calcs`.`datetime0`)+`Calcs`.`int1`, 12), 
> 2, '0'), SUBSTR(`Calcs`.`datetime0`, 8)))), SUBSTR('yyyy-MM-dd 
> HH:mm:ss',0,LENGTH(`Calcs`.`datetime0`))), 'yyyy-MM-dd HH:mm:ss') END AS 
> `none_z_dateadd_month_ok` FROM `default`.`testv1_Calcs` `Calcs` GROUP BY 
> `Calcs`.`datetime0`,   `Calcs`.`int1`,   `Calcs`.`key`,   CASE WHEN 
> (`Calcs`.`datetime0` IS NOT NULL AND `Calcs`.`int1` IS NOT NULL) THEN 
> FROM_UNIXTIME(UNIX_TIMESTAMP(CONCAT((YEAR(`Calcs`.`datetime0`)+FLOOR((MONTH(`Calcs`.`datetime0`)+`Calcs`.`int1`)/12)),
>  CONCAT('-', CONCAT(LPAD(PMOD(MONTH(`Calcs`.`datetime0`)+`Calcs`.`int1`, 12), 
> 2, '0'), SUBSTR(`Calcs`.`datetime0`, 8)))), SUBSTR('yyyy-MM-dd 
> HH:mm:ss',0,LENGTH(`Calcs`.`datetime0`))), 'yyyy-MM-dd HH:mm:ss') END ;
> {code}
> Stack Trace:
> {code}
> Caused by: java.lang.ClassCastException: org.apache.hadoop.io.IntWritable 
> cannot be cast to org.apache.hadoop.io.Text
>       at 
> org.apache.hadoop.hive.ql.udf.generic.GenericUDFBasePad.evaluate(GenericUDFBasePad.java:65)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator._evaluate(ExprNodeGenericFuncEvaluator.java:166)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:77)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator$DeferredExprObject.get(ExprNodeGenericFuncEvaluator.java:77)
>       at 
> org.apache.hadoop.hive.ql.udf.generic.GenericUDFConcat.stringEvaluate(GenericUDFConcat.java:189)
>       at 
> org.apache.hadoop.hive.ql.udf.generic.GenericUDFConcat.evaluate(GenericUDFConcat.java:159)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator._evaluate(ExprNodeGenericFuncEvaluator.java:166)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:77)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator$DeferredExprObject.get(ExprNodeGenericFuncEvaluator.java:77)
>       at 
> org.apache.hadoop.hive.ql.udf.generic.GenericUDFConcat.stringEvaluate(GenericUDFConcat.java:189)
>       at 
> org.apache.hadoop.hive.ql.udf.generic.GenericUDFConcat.evaluate(GenericUDFConcat.java:159)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator._evaluate(ExprNodeGenericFuncEvaluator.java:166)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:77)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator$DeferredExprObject.get(ExprNodeGenericFuncEvaluator.java:77)
>       at 
> org.apache.hadoop.hive.ql.udf.generic.GenericUDFConcat.stringEvaluate(GenericUDFConcat.java:189)
>       at 
> org.apache.hadoop.hive.ql.udf.generic.GenericUDFConcat.evaluate(GenericUDFConcat.java:159)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator._evaluate(ExprNodeGenericFuncEvaluator.java:166)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:77)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator$DeferredExprObject.get(ExprNodeGenericFuncEvaluator.java:77)
>       at 
> org.apache.hadoop.hive.ql.udf.generic.GenericUDFToUnixTimeStamp.evaluate(GenericUDFToUnixTimeStamp.java:121)
>       at 
> org.apache.hadoop.hive.ql.udf.generic.GenericUDFUnixTimeStamp.evaluate(GenericUDFUnixTimeStamp.java:52)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator._evaluate(ExprNodeGenericFuncEvaluator.java:166)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:77)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator$DeferredExprObject.get(ExprNodeGenericFuncEvaluator.java:77)
>       at 
> org.apache.hadoop.hive.ql.udf.generic.GenericUDFBridge.evaluate(GenericUDFBridge.java:177)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator._evaluate(ExprNodeGenericFuncEvaluator.java:166)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:77)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator$DeferredExprObject.get(ExprNodeGenericFuncEvaluator.java:77)
>       at 
> org.apache.hadoop.hive.ql.udf.generic.GenericUDFWhen.evaluate(GenericUDFWhen.java:78)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator._evaluate(ExprNodeGenericFuncEvaluator.java:166)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:77)
>       at 
> org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:65)
>       at 
> org.apache.hadoop.hive.ql.exec.KeyWrapperFactory$ListKeyWrapper.getNewKey(KeyWrapperFactory.java:113)
>       at 
> org.apache.hadoop.hive.ql.exec.GroupByOperator.processOp(GroupByOperator.java:778)
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to