Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-11278

Partition.setOutputFormatClass should not do toString for Class object

Log workAgile BoardRank to TopRank to BottomVotersWatch issueWatchersCreate sub-taskConvert to sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0
    • Component/s: None
    • Labels:
      None
    • Target Version/s:
    • Hadoop Flags:
      Reviewed

      Description

      https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/metadata/Partition.java#L286

      inside setInputFormatClass, we're doing:

       public void setInputFormatClass(Class<? extends InputFormat> inputFormatClass) {
          this.inputFormatClass = inputFormatClass;
          tPartition.getSd().setInputFormat(inputFormatClass.getName());
        }
      

      But inside setOutputFormatClass, we're doing toString for class, instead of getName().

        public void setOutputFormatClass(Class<? extends HiveOutputFormat> outputFormatClass) {
          this.outputFormatClass = outputFormatClass;
          tPartition.getSd().setOutputFormat(HiveFileFormatUtils
              .getOutputFormatSubstitute(outputFormatClass).toString());
        }
      

      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!

        Attachments

        1. HIVE-11278.01.patch
          0.8 kB
          Rajat Khandelwal

        Issue Links

          Activity

          $i18n.getText('security.level.explanation', $currentSelection) Viewable by All Users
          Cancel

            People

            • Assignee:
              prongs Rajat Khandelwal Assign to me
              Reporter:
              prongs Rajat Khandelwal

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment