hive-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rajat Khandelwal (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HIVE-11278) Partition.setOutputFormatClass should not do toString for Class object
Date Mon, 20 Jul 2015 10:17:04 GMT

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

Rajat Khandelwal commented on HIVE-11278:
-----------------------------------------

issue present since HIVE-1122: https://github.com/InMobi/hive/commit/eb4bf2e1a319e3ff95799a4757a68548b24fa262#diff-79686b532abc59fea2493c4fcd01b3a3

Just discovered while working on LENS-652. 

> Partition.setOutputFormatClass should not do toString for Class object 
> -----------------------------------------------------------------------
>
>                 Key: HIVE-11278
>                 URL: https://issues.apache.org/jira/browse/HIVE-11278
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Rajat Khandelwal
>
> https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/metadata/Partition.java#L286
> inside setInputFormatClass, we're doing:
> {noformat}
>  public void setInputFormatClass(Class<? extends InputFormat> inputFormatClass)
{
>     this.inputFormatClass = inputFormatClass;
>     tPartition.getSd().setInputFormat(inputFormatClass.getName());
>   }
> {noformat}
> But inside setOutputFormatClass, we're doing toString for class, instead of getName().
> {noformat}
>   public void setOutputFormatClass(Class<? extends HiveOutputFormat> outputFormatClass)
{
>     this.outputFormatClass = outputFormatClass;
>     tPartition.getSd().setOutputFormat(HiveFileFormatUtils
>         .getOutputFormatSubstitute(outputFormatClass).toString());
>   }
> {noformat}
> Difference is that, for Class A.class, toString is "class A.class", getName is "A.class".
So Class.forName(cls.getName()) succeeds, but Class.forName(cls.toString()) is not valid.

> So if you get a partition, set outputformat, and make an alter call, then get the partition
again and make a getOutputFormatClass call on that object, it throws a ClassNotFoundException
on https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/metadata/Partition.java#L316,
because it's basically calling Class.forName("class a.b.c.ClassName.class") which is wrong!



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

Mime
View raw message