hive-protolib/src/main/java/com/streamsets/pipeline/stage/lib/hive/HiveMetastoreUtil.java
@SuppressWarnings("unchecked")
  private static <T> void extractInnerMapFromTheList(
      Record metadataRecord,
      String listFieldName,
      String innerPairFirstFieldName,
      String innerPairSecondFieldName,
      boolean isSecondFieldHiveType,
      LinkedHashMap<String, T> returnValMap,
      HiveStageCheckedException exception
  ) throws HiveStageCheckedException{
    boolean throwException = false;
    try {
      if (metadataRecord.has(SEP + listFieldName)) {
        Field columnField = metadataRecord.get(SEP + listFieldName);
        List<Field> columnList = columnField.getValueAsList();
        if (columnList != null) {
          for (Field listElementField : columnList) {
            if (listElementField.getType() != Field.Type.MAP && listElementField.getType() != Field.Type.LIST_MAP) {
              throwException = true;
              break;
            }
            LinkedHashMap<String, Field> innerPair = listElementField.getValueAsListMap();
            String innerPairFirstField = innerPair.get(innerPairFirstFieldName).getValueAsString();
            T retVal;
            if (isSecondFieldHiveType) {
              Field hiveTypeInfoField = innerPair.get(innerPairSecondFieldName);
              HiveType hiveType = HiveType.getHiveTypeFromString(
                  hiveTypeInfoField.getValueAsMap().get(HiveMetastoreUtil.TYPE).getValueAsString()
              );
              retVal = (T) (hiveType.getSupport().generateHiveTypeInfoFromMetadataField(hiveTypeInfoField));
            } else {
              retVal = (T) innerPair.get(innerPairSecondFieldName).getValueAsString();
            }
            returnValMap.put(innerPairFirstField, retVal);
          }
        }
      } else {
        // we allow partition to be empty for non-partitioned table
        if (!listFieldName.equals(PARTITION_FIELD))
          throwException = true;
      }
    } catch(Exception e) {
      LOG.error("Can't parse metadata record", e);
      throwException = true;
      exception.initCause(e);
    }
    if (throwException) {
      throw exception;
    }
  }
@SuppressWarnings("unchecked")
  private static <T> void extractInnerMapFromTheList(
      Record metadataRecord,
      String listFieldName,
      String innerPairFirstFieldName,
      String innerPairSecondFieldName,
      boolean isSecondFieldHiveType,
      LinkedHashMap<String, T> returnValMap,
      HiveStageCheckedException exception
  ) throws HiveStageCheckedException{
    boolean throwException = false;
    try {
      if (metadataRecord.has(SEP + listFieldName)) {
        Field columnField = metadataRecord.get(SEP + listFieldName);
        List<Field> columnList = columnField.getValueAsList();
        if (columnList != null) {
          for (Field listElementField : columnList) {
            if (listElementField.getType() != Field.Type.MAP && listElementField.getType() != Field.Type.LIST_MAP) {
              throwException = true;
              break;
            }
            LinkedHashMap<String, Field> innerPair = listElementField.getValueAsListMap();
            String innerPairFirstField = innerPair.get(innerPairFirstFieldName).getValueAsString();
            T retVal;
            if (isSecondFieldHiveType) {
              Field hiveTypeInfoField = innerPair.get(innerPairSecondFieldName);
              HiveType hiveType = HiveType.getHiveTypeFromString(
                  hiveTypeInfoField.getValueAsMap().get(HiveMetastoreUtil.TYPE).getValueAsString()
              );
              retVal = (T) (hiveType.getSupport().generateHiveTypeInfoFromMetadataField(hiveTypeInfoField));
            } else {
              retVal = (T) innerPair.get(innerPairSecondFieldName).getValueAsString();
            }
            returnValMap.put(innerPairFirstField, retVal);
          }
        }
      } else {
        // we allow partition to be empty for non-partitioned table
        if (!listFieldName.equals(PARTITION_FIELD))
          throwException = true;
      }
    } catch(Exception e) {
      LOG.error("Can't parse metadata record", e);
      throwException = true;
      exception.initCause(e);
    }
    if (throwException) {
      throw exception;
    }
  }
@ SuppressWarnings ( "unchecked" ) private static < T > void extractInnerMapFromTheList ( Record metadataRecord , String listFieldName , String innerPairFirstFieldName , String innerPairSecondFieldName , boolean isSecondFieldHiveType , LinkedHashMap < String , T > returnValMap , HiveStageCheckedException exception ) throws HiveStageCheckedException { boolean throwException = false ; try { if ( metadataRecord . has ( SEP + listFieldName ) ) { Field columnField = metadataRecord . get ( SEP + listFieldName ) ; List < Field > columnList = columnField . getValueAsList ( ) ; if ( columnList != null ) { for ( Field listElementField : columnList ) { if ( listElementField . getType ( ) != Field . Type . MAP && listElementField . getType ( ) != Field . Type . LIST_MAP ) { throwException = true ; break ; } LinkedHashMap < String , Field > innerPair = listElementField . getValueAsListMap ( ) ; String innerPairFirstField = innerPair . get ( innerPairFirstFieldName ) . getValueAsString ( ) ; T retVal ; if ( isSecondFieldHiveType ) { Field hiveTypeInfoField = innerPair . get ( innerPairSecondFieldName ) ; HiveType hiveType = HiveType . getHiveTypeFromString ( hiveTypeInfoField . getValueAsMap ( ) . get ( HiveMetastoreUtil . TYPE ) . getValueAsString ( ) ) ; retVal = ( T ) ( hiveType . getSupport ( ) . generateHiveTypeInfoFromMetadataField ( hiveTypeInfoField ) ) ; } else { retVal = ( T ) innerPair . get ( innerPairSecondFieldName ) . getValueAsString ( ) ; } returnValMap . put ( innerPairFirstField , retVal ) ; } } } else { // we allow partition to be empty for non-partitioned table if ( ! listFieldName . equals ( PARTITION_FIELD ) ) throwException = true ; } } catch ( Exception e ) { LOG . error ( "Can't parse metadata record" , e ) ; throwException = true ; exception . initCause ( e ) ; } if ( throwException ) { throw exception ; } }
/*
Extract information from the list fields of form:

Column Type Information : [{name:"column1", typeInfo:{"type": "string", "extraInfo": ""}, {name:"column2", typeInfo:{"type": "int", "extraInfo": ""}]
Partition Type Information: [{name:"partition_column1", typeInfo:{"type": "date", "extraInfo": ""}, {name:"partition_column2", typeInfo:{"type": "string", "extraInfo": ""}]
Partition Value Information : [{name:"column1", value:"07-05-2016"}, {name:"column2", value:"production"}]

If any other List field path is given which does not conform  to above
form a stage exception with the mentioned error is throws.

Returns a linked hash map so as to maintain the order.
/ * Extract information from the list fields of form :