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

Caused by: java.lang.ClassCastException: org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryStruct cannot be cast to [Ljava.lang.Object;

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.0.0, 1.2.0
    • 2.0.0
    • Hive, Tez
    • None
    • Hive 1.2 and TEz 0.7

    Description

      Unreachable code:
      hive/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/StandardStructObjectInspector.java

      // With Data
      @Override
      @SuppressWarnings("unchecked")
      public Object getStructFieldData(Object data, StructField fieldRef) {
      if (data == null)

      { return null; }
      // We support both List<Object> and Object[]
      // so we have to do differently.
      boolean isArray = ! (data instanceof List);
      if (!isArray && !(data instanceof List)) { return data; }

      *************************
      The if condition above translates to
      if(!true && true) the code section cannot be reached,

      this causes a lot of class cast exceptions while using Tez or ORC file formats or custom jsonsede, Strangely this happens only while using Tez.

      Changed the code to
      boolean isArray = data.getClass().isArray();
      if (!isArray && !(data instanceof List)) { return data; }

      Even then, lazystructs get passed as fields causing downstream cast exceptions like lazystruct cannot be cast to Text etc...

      So I changed the method to something like this,

      // With Data
      @Override
      @SuppressWarnings("unchecked")
      public Object getStructFieldData(Object data, StructField fieldRef) {
      if (data == null) { return null; }

      if (data instanceof LazyBinaryStruct)

      { data = ((LazyBinaryStruct) data).getFieldsAsList(); }

      // We support both List<Object> and Object[]
      // so we have to do differently.
      boolean isArray = data.getClass().isArray();
      if (!isArray && !(data instanceof List))

      { return data; }

      This is causing arrayindexout of bounds exception and other typecast exceptions in object inspectors,

      Please help,

      Attachments

        1. HIVE-11176.1.patch.txt
          1 kB
          Navis Ryu

        Issue Links

          Activity

            People

              navis Navis Ryu
              raj_velu Soundararajan Velu
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: