Skip to content

Commit

Permalink
CR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dheyman committed Apr 2, 2024
1 parent fbf69e2 commit be0adbe
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
10 changes: 5 additions & 5 deletions src/main/java/net/snowflake/client/core/SFArrowResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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()
Expand Down Expand Up @@ -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<Object>) obj, columnIndex);
return getArrowArray((List<Object>) obj, columnIndex);
} else {
throw new SFException(ErrorCode.INVALID_STRUCT_DATA);
}
}

private SfSqlArray getArrayInternal(List<Object> elements, int columnIndex) throws SFException {
private SfSqlArray getArrowArray(List<Object> elements, int columnIndex) throws SFException {
try {
SnowflakeColumnMetadata arrayMetadata =
resultSetMetaData.getColumnMetadata().get(columnIndex - 1);
Expand Down
28 changes: 18 additions & 10 deletions src/main/java/net/snowflake/client/core/SFBaseResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/snowflake/client/core/SFJsonResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit be0adbe

Please sign in to comment.