Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CALCITE-3162] Fixed issue that arise when reading Arrays from Calcite through JdbcMeta #106

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -724,16 +724,15 @@ public static Object getSerialFromProto(Common.TypedValue protoValue) {
return Float.intBitsToFloat((int) protoValue.getNumberValue());
case INTEGER:
case PRIMITIVE_INT:
case JAVA_SQL_DATE:
case JAVA_SQL_TIME:
return Long.valueOf(protoValue.getNumberValue()).intValue();
case PRIMITIVE_SHORT:
case SHORT:
return Long.valueOf(protoValue.getNumberValue()).shortValue();
case LONG:
case PRIMITIVE_LONG:
return Long.valueOf(protoValue.getNumberValue());
case JAVA_SQL_DATE:
case JAVA_SQL_TIME:
return Long.valueOf(protoValue.getNumberValue()).intValue();
case NUMBER:
case JAVA_SQL_TIMESTAMP:
case JAVA_UTIL_DATE:
return protoValue.getNumberValue();
Expand All @@ -747,8 +746,6 @@ public static Object getSerialFromProto(Common.TypedValue protoValue) {
return new BigDecimal(bigInt, (int) protoValue.getNumberValue());
}
return new BigDecimal(protoValue.getStringValueBytes().toStringUtf8());
case NUMBER:
return Long.valueOf(protoValue.getNumberValue());
case NULL:
return null;
case ARRAY:
Expand Down Expand Up @@ -802,7 +799,7 @@ public static Common.Rep toProto(Common.TypedValue.Builder builder, Object o) {
writeToProtoWithType(builder, o, Common.Rep.DOUBLE);
return Common.Rep.DOUBLE;
} else if (o instanceof Float) {
writeToProtoWithType(builder, ((Float) o).longValue(), Common.Rep.FLOAT);
writeToProtoWithType(builder, o, Common.Rep.FLOAT);
return Common.Rep.FLOAT;
} else if (o instanceof BigDecimal) {
writeToProtoWithType(builder, o, Common.Rep.BIG_DECIMAL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.Struct;
import java.sql.Time;
import java.sql.Timestamp;
Expand Down Expand Up @@ -226,9 +225,9 @@ private static Object getValue(ResultSet resultSet, int type, int j,
try {
// Recursively extracts an Array using its ResultSet-representation
return extractUsingResultSet(array, calendar);
} catch (UnsupportedOperationException | SQLFeatureNotSupportedException e) {
// Not every database might implement Array.getResultSet(). This call
// assumes a non-nested array (depends on the db if that's a valid assumption)
} catch (Exception e) {
// Not every database might implement Array.getResultSet() using the expected structure.
// This call assumes a non-nested array (depends on the db if that's a valid assumption)
return extractUsingArray(array, calendar);
}
case Types.STRUCT:
Expand Down