in src/main/java/com/aliyun/odps/jdbc/utils/JdbcColumn.java [103:144]
public static int columnDisplaySize(TypeInfo typeInfo) throws SQLException {
// according to odpsTypeToSqlType possible options are:
int columnType = odpsTypeToSqlType(typeInfo.getOdpsType());
switch (columnType) {
case Types.NULL:
return 4; // "NULL"
case Types.BOOLEAN:
return columnPrecision(typeInfo);
case Types.CHAR:
case Types.VARCHAR:
return columnPrecision(typeInfo);
case Types.BINARY:
return Integer.MAX_VALUE; // hive has no max limit for binary
case Types.TINYINT:
case Types.SMALLINT:
case Types.INTEGER:
case Types.BIGINT:
return columnPrecision(typeInfo) + 1; // allow +/-
case Types.DATE:
return 10;
case Types.TIMESTAMP:
return columnPrecision(typeInfo);
// see
// http://download.oracle.com/javase/6/docs/api/constant-values.html#java.lang.Float.MAX_EXPONENT
case Types.FLOAT:
return 24; // e.g. -(17#).e-###
// see
// http://download.oracle.com/javase/6/docs/api/constant-values.html#java.lang.Double.MAX_EXPONENT
case Types.DOUBLE:
return 25; // e.g. -(17#).e-####
case Types.DECIMAL:
return columnPrecision(typeInfo) + 2; // '-' sign and '.'
case Types.OTHER:
case Types.JAVA_OBJECT:
return columnPrecision(typeInfo);
case Types.ARRAY:
case Types.STRUCT:
return Integer.MAX_VALUE;
default:
throw new SQLException("Invalid odps type: " + columnType);
}
}