private String getDecoratedTypeName(String typeName, SupportedTypes supportedTypes, int depth, int maxDepth) {
    depth++;
    if (depth < maxDepth) {
      supportedTypes = SupportedTypes.PRIMITIVE;
    }
    if (typeName.equals("char")) {
      int maxLength = 1 + r.nextInt(100);
      typeName = String.format("char(%d)", maxLength);
    } else if (typeName.equals("varchar")) {
      int maxLength = 1 + r.nextInt(100);
      typeName = String.format("varchar(%d)", maxLength);
    } else if (typeName.equals("decimal")) {
      typeName = String.format("decimal(%d,%d)", HiveDecimal.SYSTEM_DEFAULT_PRECISION, HiveDecimal.SYSTEM_DEFAULT_SCALE);
    } else if (typeName.equals("array")) {
      String elementTypeName = getRandomTypeName(supportedTypes);
      elementTypeName = getDecoratedTypeName(elementTypeName, supportedTypes, depth, maxDepth);
      typeName = String.format("array<%s>", elementTypeName);
    } else if (typeName.equals("map")) {
      String keyTypeName = getRandomTypeName(SupportedTypes.PRIMITIVE);
      keyTypeName = getDecoratedTypeName(keyTypeName, supportedTypes, depth, maxDepth);
      String valueTypeName = getRandomTypeName(supportedTypes);
      valueTypeName = getDecoratedTypeName(valueTypeName, supportedTypes, depth, maxDepth);
      typeName = String.format("map<%s,%s>", keyTypeName, valueTypeName);
    } else if (typeName.equals("struct")) {
      final int fieldCount = 1 + r.nextInt(10);
      StringBuilder sb = new StringBuilder();
      for (int i = 0; i < fieldCount; i++) {
        String fieldTypeName = getRandomTypeName(supportedTypes);
        fieldTypeName = getDecoratedTypeName(fieldTypeName, supportedTypes, depth, maxDepth);
        if (i > 0) {
          sb.append(",");
        }
        sb.append("col");
        sb.append(i);
        sb.append(":");
        sb.append(fieldTypeName);
      }
      typeName = String.format("struct<%s>", sb.toString());
    } else if (typeName.equals("struct") ||
      typeName.equals("uniontype")) {
      final int fieldCount = 1 + r.nextInt(10);
      final StringBuilder sb = new StringBuilder();
      for (int i = 0; i < fieldCount; i++) {
      String fieldTypeName = getRandomTypeName(supportedTypes);
      fieldTypeName = getDecoratedTypeName(fieldTypeName, supportedTypes, depth, maxDepth);
      if (i > 0) {
        sb.append(",");
      }
      sb.append(fieldTypeName);
      }
      typeName = String.format("uniontype<%s>", sb.toString());
    }
    return typeName;
  }
Generate object inspector and random row object[].
serde/src/test/org/apache/hadoop/hive/serde2/SerdeRandomRowSource.java