hive-json-schema icon indicating copy to clipboard operation
hive-json-schema copied to clipboard

Use bigint for Long values

Open tlbollwitt opened this issue 7 years ago • 1 comments

The generated table definition uses 'int' data types for values that are longs. The 'curated' JSON document used Long.MAX_VALUE as the field value.

The scalarNumericType() method should probably attempt convert the value to an int and if that fails then return bigint instead of int.

tlbollwitt avatar Apr 07 '17 16:04 tlbollwitt

I add some codes and have no problem. Please refer this.

private String scalarNumericType(Object o) {
    String s = o.toString();
    System.out.println(s.getClass().getName());
    if (s.indexOf('.') > 0) {
      return "double";
    }
    else if(Long.parseLong(s) > Integer.MAX_VALUE){
      return "bigint";
    }
    else {
      return "int";
    }
  }

Taaewoo avatar Dec 04 '22 17:12 Taaewoo