hive-json-schema
hive-json-schema copied to clipboard
Use bigint for Long values
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.
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";
}
}