Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Commit e4e0b2a

Browse files
authored
Merge pull request #5 from polypheny/pull-requests-from-ppanopticon
Merge [[CALCITE-3163]](apache#105) and [[CALCITE-3162]](apache#106)
2 parents ed9e803 + 69838b0 commit e4e0b2a

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

core/src/main/java/org/apache/calcite/avatica/remote/TypedValue.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -724,16 +724,15 @@ public static Object getSerialFromProto(Common.TypedValue protoValue) {
724724
return Float.intBitsToFloat((int) protoValue.getNumberValue());
725725
case INTEGER:
726726
case PRIMITIVE_INT:
727+
case JAVA_SQL_DATE:
728+
case JAVA_SQL_TIME:
727729
return Long.valueOf(protoValue.getNumberValue()).intValue();
728730
case PRIMITIVE_SHORT:
729731
case SHORT:
730732
return Long.valueOf(protoValue.getNumberValue()).shortValue();
731733
case LONG:
732734
case PRIMITIVE_LONG:
733-
return Long.valueOf(protoValue.getNumberValue());
734-
case JAVA_SQL_DATE:
735-
case JAVA_SQL_TIME:
736-
return Long.valueOf(protoValue.getNumberValue()).intValue();
735+
case NUMBER:
737736
case JAVA_SQL_TIMESTAMP:
738737
case JAVA_UTIL_DATE:
739738
return protoValue.getNumberValue();
@@ -747,8 +746,6 @@ public static Object getSerialFromProto(Common.TypedValue protoValue) {
747746
return new BigDecimal(bigInt, (int) protoValue.getNumberValue());
748747
}
749748
return new BigDecimal(protoValue.getStringValueBytes().toStringUtf8());
750-
case NUMBER:
751-
return Long.valueOf(protoValue.getNumberValue());
752749
case NULL:
753750
return null;
754751
case ARRAY:
@@ -802,7 +799,7 @@ public static Common.Rep toProto(Common.TypedValue.Builder builder, Object o) {
802799
writeToProtoWithType(builder, o, Common.Rep.DOUBLE);
803800
return Common.Rep.DOUBLE;
804801
} else if (o instanceof Float) {
805-
writeToProtoWithType(builder, ((Float) o).longValue(), Common.Rep.FLOAT);
802+
writeToProtoWithType(builder, o, Common.Rep.FLOAT);
806803
return Common.Rep.FLOAT;
807804
} else if (o instanceof BigDecimal) {
808805
writeToProtoWithType(builder, o, Common.Rep.BIG_DECIMAL);

core/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1318,8 +1318,9 @@ private Object convertValue() throws SQLException {
13181318
return componentAccessor.getInt();
13191319
case Types.BIGINT:
13201320
return componentAccessor.getLong();
1321-
case Types.FLOAT:
1321+
case Types.REAL:
13221322
return componentAccessor.getFloat();
1323+
case Types.FLOAT:
13231324
case Types.DOUBLE:
13241325
return componentAccessor.getDouble();
13251326
case Types.ARRAY:

server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcResultSet.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.sql.ResultSet;
3333
import java.sql.ResultSetMetaData;
3434
import java.sql.SQLException;
35-
import java.sql.SQLFeatureNotSupportedException;
3635
import java.sql.Struct;
3736
import java.sql.Time;
3837
import java.sql.Timestamp;
@@ -226,9 +225,9 @@ private static Object getValue(ResultSet resultSet, int type, int j,
226225
try {
227226
// Recursively extracts an Array using its ResultSet-representation
228227
return extractUsingResultSet(array, calendar);
229-
} catch (UnsupportedOperationException | SQLFeatureNotSupportedException e) {
230-
// Not every database might implement Array.getResultSet(). This call
231-
// assumes a non-nested array (depends on the db if that's a valid assumption)
228+
} catch (Exception e) {
229+
// Not every database might implement Array.getResultSet() using the expected structure.
230+
// This call assumes a non-nested array (depends on the db if that's a valid assumption)
232231
return extractUsingArray(array, calendar);
233232
}
234233
case Types.STRUCT:

0 commit comments

Comments
 (0)