Skip to content

Commit

Permalink
SNOW-1234216 Add checks for structured types for getMap and getArray …
Browse files Browse the repository at this point in the history
…methods
  • Loading branch information
sfc-gh-dheyman committed Apr 3, 2024
1 parent 55d4e6c commit 43e79ab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import net.snowflake.client.core.SFBaseSession;
import net.snowflake.client.core.SFException;
import net.snowflake.client.core.structs.SQLDataCreationHelper;
import net.snowflake.client.core.structs.StructureTypeHelper;
import net.snowflake.client.log.SFLogger;
import net.snowflake.client.log.SFLoggerFactory;
import net.snowflake.common.core.SqlState;
Expand Down Expand Up @@ -1405,6 +1406,10 @@ public <T> List<T> getList(int columnIndex, Class<T> type) throws SQLException {
}

public <T> T[] getArray(int columnIndex, Class<T> type) throws SQLException {
logger.debug("public <T> T[] getArray(int columnIndex, Class<T> type)", false);
if (!StructureTypeHelper.isStructureTypeEnabled()) {
throw new SnowflakeLoggedFeatureNotSupportedException(session);
}
FieldMetadata fieldMetadata =
sfBaseResultSet.getMetaData().getColumnMetadata().get(columnIndex - 1).getFields().get(0);
int columnSubType = fieldMetadata.getType();
Expand Down Expand Up @@ -1545,6 +1550,10 @@ public <T> T[] getArray(int columnIndex, Class<T> type) throws SQLException {
}

public <T> Map<String, T> getMap(int columnIndex, Class<T> type) throws SQLException {
logger.debug("public <T> Map<String, T> getMap(int columnIndex, Class<T> type)", false);
if (!StructureTypeHelper.isStructureTypeEnabled()) {
throw new SnowflakeLoggedFeatureNotSupportedException(session);
}
FieldMetadata valueFieldMetadata =
sfBaseResultSet.getMetaData().getColumnMetadata().get(columnIndex - 1).getFields().get(1);
int columnSubType = valueFieldMetadata.getType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import net.snowflake.client.core.QueryStatus;
import net.snowflake.client.core.SFBaseResultSet;
import net.snowflake.client.core.SFException;
import net.snowflake.client.core.structs.StructureTypeHelper;

/** Snowflake ResultSet implementation */
public class SnowflakeResultSetV1 extends SnowflakeBaseResultSet
Expand Down Expand Up @@ -272,6 +273,9 @@ public Object getObject(int columnIndex) throws SQLException {
}

public Array getArray(int columnIndex) throws SQLException {
if (!StructureTypeHelper.isStructureTypeEnabled()) {
throw new SnowflakeLoggedFeatureNotSupportedException(session);
}
raiseSQLExceptionIfResultSetIsClosed();
try {
return sfBaseResultSet.getArray(columnIndex);
Expand Down

0 comments on commit 43e79ab

Please sign in to comment.