Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dheyman committed Mar 28, 2024
1 parent 2659cde commit 882c810
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
5 changes: 1 addition & 4 deletions src/main/java/net/snowflake/client/core/ArrowSqlInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,7 @@ public <T> T readObject(Class<T> type) throws SQLException {
SQLData instance = (SQLData) SQLDataCreationHelper.create(type);
instance.readSQL(
new ArrowSqlInput(
(Map<String, Object>) value,
session,
converters,
fieldMetadata.getFields()),
(Map<String, Object>) value, session, converters, fieldMetadata.getFields()),
null);
return (T) instance;
});
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/net/snowflake/client/core/SFArrowResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,23 +365,21 @@ public Converters getConverters() {

@Override
public Date convertToDate(Object object, TimeZone tz) throws SFException {
return converters
.getStructuredTypeDateTimeConverter()
.getDate((int) object, tz);
return converters.getStructuredTypeDateTimeConverter().getDate((int) object, tz);
}

@Override
public Time convertToTime(Object object, int scale) throws SFException {
return converters.getStructuredTypeDateTimeConverter()
.getTime((long) object, scale);
return converters.getStructuredTypeDateTimeConverter().getTime((long) object, scale);
}

@Override
public Timestamp convertToTimestamp(Object object, int columnType, int columnSubType, TimeZone tz, int scale) throws SFException {
return converters
.getStructuredTypeDateTimeConverter()
.getTimestamp(
(JsonStringHashMap<String, Object>) object, columnType, columnSubType, tz, scale);
public Timestamp convertToTimestamp(
Object object, int columnType, int columnSubType, TimeZone tz, int scale) throws SFException {
return converters
.getStructuredTypeDateTimeConverter()
.getTimestamp(
(JsonStringHashMap<String, Object>) object, columnType, columnSubType, tz, scale);
}

/**
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/net/snowflake/client/core/SFBaseResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ public boolean isArrayBindSupported() {
* data size.
*
* @param maxSizeInBytes The expected max data size wrapped in the ResultSetSerializables object.
* NOTE: this parameter is intended to make the data size in each serializable object to be
* less than it. But if user specifies a small value which may be smaller than the data size
* of one result chunk. So the definition can't be guaranteed completely. For this special
* case, one serializable object is used to wrap the data chunk.
* NOTE: this parameter is intended to make the data size in each serializable object to be
* less than it. But if user specifies a small value which may be smaller than the data size
* of one result chunk. So the definition can't be guaranteed completely. For this special
* case, one serializable object is used to wrap the data chunk.
* @return a list of SnowflakeResultSetSerializable
* @throws SQLException if fails to split objects.
*/
public List<SnowflakeResultSetSerializable> getResultSetSerializables(long maxSizeInBytes)
throws SQLException {
throws SQLException {
return this.resultSetSerializable.splitBySize(maxSizeInBytes);
}

Expand All @@ -222,6 +222,5 @@ public TimeZone getSessionTimeZone() {

@SnowflakeJdbcInternalApi
public abstract Timestamp convertToTimestamp(
Object object, int columnType, int columnSubType, TimeZone tz, int scale) throws SFException;
Object object, int columnType, int columnSubType, TimeZone tz, int scale) throws SFException;
}

6 changes: 4 additions & 2 deletions src/main/java/net/snowflake/client/core/SFJsonResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,10 @@ public Time convertToTime(Object object, int scale) throws SFException {
}

@Override
public Timestamp convertToTimestamp(Object object, int columnType, int columnSubType, TimeZone tz, int scale) throws SFException {
return (Timestamp) converters
public Timestamp convertToTimestamp(
Object object, int columnType, int columnSubType, TimeZone tz, int scale) throws SFException {
return (Timestamp)
converters
.timestampConverter(columnSubType, columnType, scale, session, null, tz)
.convert((String) object);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@
import net.snowflake.client.core.ColumnTypeHelper;
import net.snowflake.client.core.JsonSqlInput;
import net.snowflake.client.core.ObjectMapperFactory;
import net.snowflake.client.core.SFArrowResultSet;
import net.snowflake.client.core.SFBaseResultSet;
import net.snowflake.client.core.SFBaseSession;
import net.snowflake.client.core.SFException;
import net.snowflake.client.core.structs.SQLDataCreationHelper;
import net.snowflake.client.log.SFLogger;
import net.snowflake.client.log.SFLoggerFactory;
import net.snowflake.common.core.SqlState;
import org.apache.arrow.vector.util.JsonStringHashMap;

/** Base class for query result set and metadata result set */
public abstract class SnowflakeBaseResultSet implements ResultSet {
Expand Down Expand Up @@ -1589,7 +1586,10 @@ public <T> Map<String, T> getMap(int columnIndex, Class<T> type) throws SQLExcep
.get(columnIndex - 1)
.getFields());
} else {
throw new SQLException("SqlInput type " + object.getClass() + " is not supported when mapping to SQLData class");
throw new SQLException(
"SqlInput type "
+ object.getClass()
+ " is not supported when mapping to SQLData class");
}
instance.readSQL(sqlInput, null);
resultMap.put(entry.getKey(), (T) instance);
Expand Down Expand Up @@ -1691,17 +1691,21 @@ public <T> Map<String, T> getMap(int columnIndex, Class<T> type) throws SQLExcep
} else if (Date.class.isAssignableFrom(type)) {
resultMap.put(
entry.getKey(),
mapSFExceptionToSQLException(() -> (T) sfBaseResultSet.convertToDate(entry.getValue(), tz)));
mapSFExceptionToSQLException(
() -> (T) sfBaseResultSet.convertToDate(entry.getValue(), tz)));
} else if (Time.class.isAssignableFrom(type)) {
resultMap.put(
entry.getKey(),
mapSFExceptionToSQLException(() -> (T) sfBaseResultSet.convertToTime(entry.getValue(), scale)));
mapSFExceptionToSQLException(
() -> (T) sfBaseResultSet.convertToTime(entry.getValue(), scale)));

} else if (Timestamp.class.isAssignableFrom(type)) {
resultMap.put(
entry.getKey(),
mapSFExceptionToSQLException(
() -> (T) sfBaseResultSet.convertToTimestamp(
() ->
(T)
sfBaseResultSet.convertToTimestamp(
entry.getValue(), columnType, columnSubType, tz, scale)));

} else {
Expand Down

0 comments on commit 882c810

Please sign in to comment.