diff --git a/core/src/main/java/org/apache/calcite/avatica/remote/TypedValue.java b/core/src/main/java/org/apache/calcite/avatica/remote/TypedValue.java index 9b98d2abb2..6e3c090b12 100644 --- a/core/src/main/java/org/apache/calcite/avatica/remote/TypedValue.java +++ b/core/src/main/java/org/apache/calcite/avatica/remote/TypedValue.java @@ -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(); @@ -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: @@ -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); diff --git a/server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcResultSet.java b/server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcResultSet.java index 7aa7a731db..0b2da5d5a9 100644 --- a/server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcResultSet.java +++ b/server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcResultSet.java @@ -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; @@ -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: