Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.snowflake.client.api.exception.SnowflakeSQLException;
import net.snowflake.client.api.resultset.FieldMetadata;
import net.snowflake.client.api.resultset.SnowflakeResultSetMetaData;
import net.snowflake.client.api.resultset.SnowflakeType;
import net.snowflake.client.internal.core.SFBaseSession;
import net.snowflake.client.internal.core.SFException;
import net.snowflake.client.internal.core.SFResultSetMetaData;
Expand Down Expand Up @@ -123,6 +124,9 @@ public boolean isAutoIncrement(int column) throws SQLException {
@Override
public boolean isCaseSensitive(int column) throws SQLException {
int colType = getColumnType(column);
if (colType == SnowflakeType.EXTRA_TYPES_VECTOR) {
colType = Types.VARCHAR;
}

switch (colType) {
// Note: SF types GEOGRAPHY, GEOMETRY are also represented as VARCHAR.
Expand Down Expand Up @@ -177,6 +181,9 @@ public String getColumnClassName(int column) throws SQLException {
logger.trace("String getColumnClassName(int column)", false);

int type = this.getColumnType(column);
if (type == SnowflakeType.EXTRA_TYPES_VECTOR) {
type = Types.VARCHAR;
}

return SnowflakeTypeUtil.javaTypeToClassName(type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import net.snowflake.client.api.exception.ErrorCode;
import net.snowflake.client.api.exception.SnowflakeSQLException;
import net.snowflake.client.api.resultset.SnowflakeResultSetMetaData;
import net.snowflake.client.api.resultset.SnowflakeType;
import net.snowflake.client.category.TestTags;
import net.snowflake.client.internal.api.implementation.connection.SnowflakeConnectionImpl;
import net.snowflake.client.internal.api.implementation.resultset.SnowflakeBaseResultSet;
Expand Down Expand Up @@ -672,6 +673,19 @@ public void testGetDataTypeWithTimestampTz(String queryResultFormat) throws Exce
}
}

@ParameterizedTest
@ArgumentsSource(SimpleResultFormatProvider.class)
public void testGetDataTypeWithVector(String queryResultFormat) throws SQLException {
try (Statement statement = createStatement(queryResultFormat)) {
statement.execute("create or replace table vector_test(v vector(int, 3))");
try (ResultSet resultSet = statement.executeQuery("select * from vector_test")) {
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
assertEquals(SnowflakeType.EXTRA_TYPES_VECTOR, resultSetMetaData.getColumnType(1));
assertEquals(String.class.getName(), resultSetMetaData.getColumnClassName(1));
}
}
}

/**
* Test getClob(int), and getClob(String) handle SQL nulls and don't throw a NullPointerException
* (SNOW-749517)
Expand Down Expand Up @@ -908,7 +922,8 @@ public void testMetadataIsCaseSensitive(String queryResultFormat) throws SQLExce
+ " array_col1 ARRAY,"
+ " text_col1 TEXT,"
+ " varchar_col VARCHAR(16777216),"
+ " char_col CHAR(16777216)"
+ " char_col CHAR(16777216),"
+ " vector_col VECTOR(INT, 3)"
+ ");";

statement.execute(sampleCreateTableWithAllColTypes);
Expand All @@ -933,6 +948,7 @@ public void testMetadataIsCaseSensitive(String queryResultFormat) throws SQLExce
assertTrue(metaData.isCaseSensitive(15)); // TEXT
assertTrue(metaData.isCaseSensitive(16)); // VARCHAR
assertTrue(metaData.isCaseSensitive(17)); // CHAR
assertTrue(metaData.isCaseSensitive(18)); // VECTOR
}
}
}
Expand Down
Loading