public static HiveDecimal getRandHiveDecimal(Random r, DecimalTypeInfo decimalTypeInfo) {
    while (true) {
      final StringBuilder sb = new StringBuilder();
      final int precision = 1 + r.nextInt(18);
      final int scale = 0 + r.nextInt(precision + 1);

      final int integerDigits = precision - scale;

      if (r.nextBoolean()) {
        sb.append("-");
      }

      if (integerDigits == 0) {
        sb.append("0");
      } else {
        sb.append(RandomTypeUtil.getRandString(r, DECIMAL_CHARS, integerDigits));
      }
      if (scale != 0) {
        sb.append(".");
        sb.append(RandomTypeUtil.getRandString(r, DECIMAL_CHARS, scale));
      }

      HiveDecimal dec = HiveDecimal.create(sb.toString());
      dec =
          HiveDecimal.enforcePrecisionScale(
              dec, decimalTypeInfo.getPrecision(), decimalTypeInfo.getScale());
      if (dec != null) {
        return dec;
      }
    }
  }
Generate object inspector and random row object[].
ql/src/test/org/apache/hadoop/hive/ql/exec/vector/VectorRandomRowSource.java