in src/main/java/com/aliyun/odps/jdbc/utils/transformer/to/jdbc/ToJdbcDoubleTransformer.java [44:75]
public Object transform(Object o, String charset) throws SQLException {
if (o == null) {
return (double) 0;
}
try {
if (o instanceof Number) {
return ((Number) o).doubleValue();
} else if (o instanceof Boolean) {
return (Boolean) o ? (Double) 1d : (Double) 0d;
} else if (o instanceof byte[]) {
String str = encodeBytes((byte[]) o, charset);
return Double.parseDouble(str);
} else if (o instanceof String) {
String str = (String) o;
return Double.parseDouble(str);
} else if (o instanceof AbstractChar) {
return Double.parseDouble(((AbstractChar) o).getValue());
} else if (o instanceof Binary) {
String str = encodeBytes(((Binary) o).data(), charset);
return Double.parseDouble(str);
} else {
String errorMsg = getInvalidTransformationErrorMsg(o.getClass(), Double.class);
throw new SQLException(errorMsg);
}
} catch (SQLException e) {
throw e;
} catch (Exception e) {
String errorMsg = getTransformationErrMsg(Objects.toString(o), Double.class, e.getMessage());
throw new SQLException(errorMsg, e);
}
}