From be0adbef94c8e0cbfaff8a10f416034519e0d6fd Mon Sep 17 00:00:00 2001 From: Dawid Heyman Date: Tue, 2 Apr 2024 14:58:07 +0200 Subject: [PATCH] CR suggestions --- .../client/core/SFArrowResultSet.java | 10 +++---- .../client/core/SFBaseResultSet.java | 28 ++++++++++++------- .../client/core/SFJsonResultSet.java | 8 +++--- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/main/java/net/snowflake/client/core/SFArrowResultSet.java b/src/main/java/net/snowflake/client/core/SFArrowResultSet.java index 9d6a467b9..2a8e34af3 100644 --- a/src/main/java/net/snowflake/client/core/SFArrowResultSet.java +++ b/src/main/java/net/snowflake/client/core/SFArrowResultSet.java @@ -389,7 +389,7 @@ public SQLInput createSqlInputForColumn( @SnowflakeJdbcInternalApi public Date convertToDate(Object object, TimeZone tz) throws SFException { if (object instanceof String) { - return convertStringToDate(object, tz); + return convertStringToDate((String) object, tz); } return converters.getStructuredTypeDateTimeConverter().getDate((int) object, tz); } @@ -398,7 +398,7 @@ public Date convertToDate(Object object, TimeZone tz) throws SFException { @SnowflakeJdbcInternalApi public Time convertToTime(Object object, int scale) throws SFException { if (object instanceof String) { - return convertStringToTime(object, scale); + return convertStringToTime((String) object, scale); } return converters.getStructuredTypeDateTimeConverter().getTime((long) object, scale); } @@ -408,7 +408,7 @@ public Time convertToTime(Object object, int scale) throws SFException { public Timestamp convertToTimestamp( Object object, int columnType, int columnSubType, TimeZone tz, int scale) throws SFException { if (object instanceof String) { - return convertStringToTimestamp(object, columnType, columnSubType, tz, scale); + return convertStringToTimestamp((String) object, columnType, columnSubType, tz, scale); } return converters .getStructuredTypeDateTimeConverter() @@ -607,13 +607,13 @@ public Array getArray(int columnIndex) throws SFException { if (converter instanceof VarCharConverter) { return getJsonArrayInternal((String) obj, columnIndex); } else if (converter instanceof ArrayConverter) { - return getArrayInternal((List) obj, columnIndex); + return getArrowArray((List) obj, columnIndex); } else { throw new SFException(ErrorCode.INVALID_STRUCT_DATA); } } - private SfSqlArray getArrayInternal(List elements, int columnIndex) throws SFException { + private SfSqlArray getArrowArray(List elements, int columnIndex) throws SFException { try { SnowflakeColumnMetadata arrayMetadata = resultSetMetaData.getColumnMetadata().get(columnIndex - 1); diff --git a/src/main/java/net/snowflake/client/core/SFBaseResultSet.java b/src/main/java/net/snowflake/client/core/SFBaseResultSet.java index 26c2bde26..4be1e3418 100644 --- a/src/main/java/net/snowflake/client/core/SFBaseResultSet.java +++ b/src/main/java/net/snowflake/client/core/SFBaseResultSet.java @@ -235,18 +235,26 @@ public TimeZone getSessionTimeZone() { } @SnowflakeJdbcInternalApi - public abstract SQLInput createSqlInputForColumn( - Object input, Class parentObjectClass, int columnIndex, SFBaseSession session); + protected SQLInput createSqlInputForColumn( + Object input, Class parentObjectClass, int columnIndex, SFBaseSession session) { + throw new UnsupportedOperationException(); + } @SnowflakeJdbcInternalApi - public abstract Date convertToDate(Object object, TimeZone tz) throws SFException; + protected Date convertToDate(Object object, TimeZone tz) throws SFException { + throw new UnsupportedOperationException(); + } @SnowflakeJdbcInternalApi - public abstract Time convertToTime(Object object, int scale) throws SFException; + protected Time convertToTime(Object object, int scale) throws SFException { + throw new UnsupportedOperationException(); + } @SnowflakeJdbcInternalApi - public abstract Timestamp convertToTimestamp( - Object object, int columnType, int columnSubType, TimeZone tz, int scale) throws SFException; + protected Timestamp convertToTimestamp( + Object object, int columnType, int columnSubType, TimeZone tz, int scale) throws SFException { + throw new UnsupportedOperationException(); + } @SnowflakeJdbcInternalApi protected SQLInput createJsonSqlInputForColumn( @@ -266,7 +274,7 @@ protected SQLInput createJsonSqlInputForColumn( } @SnowflakeJdbcInternalApi - protected SfSqlArray getJsonArrayInternal(String obj, int columnIndex) throws SFException { + protected SfSqlArray getJsonArray(String obj, int columnIndex) throws SFException { try { SnowflakeColumnMetadata arrayMetadata = resultSetMetaData.getColumnMetadata().get(columnIndex - 1); @@ -376,18 +384,18 @@ protected SfSqlArray getJsonArrayInternal(String obj, int columnIndex) throws SF } @SnowflakeJdbcInternalApi - protected Date convertStringToDate(Object object, TimeZone tz) throws SFException { + protected Date convertStringToDate(String object, TimeZone tz) throws SFException { return (Date) getConverters().dateStringConverter(session).convert(object); } @SnowflakeJdbcInternalApi - protected Time convertStringToTime(Object object, int scale) throws SFException { + protected Time convertStringToTime(String object, int scale) throws SFException { return (Time) getConverters().timeFromStringConverter(session).convert(object); } @SnowflakeJdbcInternalApi protected Timestamp convertStringToTimestamp( - Object object, int columnType, int columnSubType, TimeZone tz, int scale) throws SFException { + String object, int columnType, int columnSubType, TimeZone tz, int scale) throws SFException { return (Timestamp) getConverters() .timestampFromStringConverter(columnSubType, columnType, scale, session, null, tz) diff --git a/src/main/java/net/snowflake/client/core/SFJsonResultSet.java b/src/main/java/net/snowflake/client/core/SFJsonResultSet.java index 4d9eec3f4..ea69597b1 100644 --- a/src/main/java/net/snowflake/client/core/SFJsonResultSet.java +++ b/src/main/java/net/snowflake/client/core/SFJsonResultSet.java @@ -118,7 +118,7 @@ private Object getBigInt(int columnIndex, Object obj) throws SFException { @Override public Array getArray(int columnIndex) throws SFException { Object obj = getObjectInternal(columnIndex); - return getJsonArrayInternal((String) obj, columnIndex); + return getJsonArray((String) obj, columnIndex); } @Override @@ -259,20 +259,20 @@ public SQLInput createSqlInputForColumn( @Override @SnowflakeJdbcInternalApi public Date convertToDate(Object object, TimeZone tz) throws SFException { - return convertStringToDate(object, tz); + return convertStringToDate((String) object, tz); } @Override @SnowflakeJdbcInternalApi public Time convertToTime(Object object, int scale) throws SFException { - return convertStringToTime(object, scale); + return convertStringToTime((String) object, scale); } @Override @SnowflakeJdbcInternalApi public Timestamp convertToTimestamp( Object object, int columnType, int columnSubType, TimeZone tz, int scale) throws SFException { - return convertStringToTimestamp(object, columnType, columnSubType, tz, scale); + return convertStringToTimestamp((String) object, columnType, columnSubType, tz, scale); } private Timestamp getTimestamp(int columnIndex) throws SFException {