in java-client/src/main/java/co/elastic/clients/elasticsearch/_helpers/esql/jdbc/TypeConverter.java [207:262]
static Object convert(Object v, EsType columnType, String typeString) throws SQLException {
switch (columnType) {
case NULL:
return null;
case BOOLEAN:
case TEXT:
case KEYWORD:
return v; // These types are already represented correctly in JSON
case BYTE:
return ((Number) v).byteValue(); // Parser might return it as integer or long - need to update to the correct type
case SHORT:
return ((Number) v).shortValue(); // Parser might return it as integer or long - need to update to the correct type
case INTEGER:
return ((Number) v).intValue();
case LONG:
return ((Number) v).longValue();
case UNSIGNED_LONG:
return asBigInteger(v, columnType, typeString);
case HALF_FLOAT:
case SCALED_FLOAT:
case DOUBLE:
return doubleValue(v); // Double might be represented as string for infinity and NaN values
case FLOAT:
return floatValue(v); // Float might be represented as string for infinity and NaN values
case DATE:
return asDateTimeField(v, JdbcDateUtils::asDate, Date::new);
case TIME:
return timeAsTime(v.toString());
case DATETIME:
return asDateTimeField(v, JdbcDateUtils::asTimestamp, Timestamp::new);
case INTERVAL_YEAR:
case INTERVAL_MONTH:
case INTERVAL_YEAR_TO_MONTH:
return Period.parse(v.toString());
case INTERVAL_DAY:
case INTERVAL_HOUR:
case INTERVAL_MINUTE:
case INTERVAL_SECOND:
case INTERVAL_DAY_TO_HOUR:
case INTERVAL_DAY_TO_MINUTE:
case INTERVAL_DAY_TO_SECOND:
case INTERVAL_HOUR_TO_MINUTE:
case INTERVAL_HOUR_TO_SECOND:
case INTERVAL_MINUTE_TO_SECOND:
return Duration.parse(v.toString());
case GEO_POINT:
case GEO_SHAPE:
case SHAPE:
case IP:
case VERSION:
return v.toString();
default:
throw new SQLException("Unexpected column type [" + typeString + "]");
}
}