private StructField getStructField(final StructObjectInspector oi,
      final String fieldName) throws SerDeException {

    final Pair<StructObjectInspector, String> pair =
        ImmutablePair.of(oi, fieldName);

    // Ignore the field if it has been ignored before
    if (this.discoveredUnknownFields.contains(pair)) {
      return null;
    }

    // Return from cache if the field has already been discovered
    StructField structField = this.discoveredFields.get(pair);
    if (structField != null) {
      return structField;
    }

    // Otherwise attempt to discover the field
    if (isEnabled(Feature.COL_INDEX_PARSING)) {
      int colIndex = getColIndex(fieldName);
      if (colIndex >= 0) {
        structField = oi.getAllStructFieldRefs().get(colIndex);
      }
    }
    if (structField == null) {
      try {
        structField = oi.getStructFieldRef(fieldName);
      } catch (Exception e) {
        // No such field
      }
    }
    if (structField != null) {
      // cache it for next time
      this.discoveredFields.put(pair, structField);
    } else {
      // Tried everything and did not discover this field
      if (isEnabled(Feature.IGNORE_UNKNOWN_FIELDS)
          && this.discoveredUnknownFields.add(pair)) {
        LOG.warn("Discovered unknown field: {}. Ignoring.", fieldName);
      } else {
        throw new SerDeException(
            "Field found in JSON does not match table definition: "
                + fieldName);
      }
    }

    return structField;
  }
Matches the JSON object's field name with the Hive data type.

@param oi The ObjectInspector to lookup the matching in
@param fieldName The name of the field parsed from the JSON text
@return The meta data of regarding this field
@throws SerDeException The SerDe is not configured correctly
serde/src/java/org/apache/hadoop/hive/serde2/json/HiveJsonReader.java