Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1960848 - fix tests after MaxLobSize changes #2109

Merged
merged 6 commits into from
Mar 12, 2025
Merged
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 @@ -2,6 +2,7 @@

import static net.snowflake.client.jdbc.DatabaseMetaDataInternalIT.endMetaData;
import static net.snowflake.client.jdbc.DatabaseMetaDataInternalIT.initMetaData;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

Expand Down Expand Up @@ -176,9 +177,13 @@ public void testGetFunctionColumns() throws SQLException {
databaseMetaData.getMaxCharLiteralLength(), resultSet.getInt("CHAR_OCTET_LENGTH"));
assertEquals(1, resultSet.getInt("ORDINAL_POSITION"));
assertEquals("", resultSet.getString("IS_NULLABLE"));
assertEquals(
"FUNC112() RETURN TABLE (COLA VARCHAR, COLB NUMBER, BIN2 BINARY, SHAREDCOL NUMBER)",
resultSet.getString("SPECIFIC_NAME"));
assertThat(
"Columns metadata SPECIFIC_NAME should contains expected columns ",
resultSet
.getString("SPECIFIC_NAME")
.replaceAll("\\s", "")
.matches(
"^FUNC112.*RETURNTABLE.*COLAVARCHAR.*,COLBNUMBER,BIN2BINARY.*,SHAREDCOLNUMBER.?$"));
resultSet.next();
assertEquals("JDBC_DB1", resultSet.getString("FUNCTION_CAT"));
assertEquals("JDBC_SCHEMA11", resultSet.getString("FUNCTION_SCHEM"));
Expand All @@ -196,9 +201,13 @@ public void testGetFunctionColumns() throws SQLException {
assertEquals(0, resultSet.getInt("CHAR_OCTET_LENGTH"));
assertEquals(2, resultSet.getInt("ORDINAL_POSITION"));
assertEquals("", resultSet.getString("IS_NULLABLE"));
assertEquals(
"FUNC112() RETURN TABLE (COLA VARCHAR, COLB NUMBER, BIN2 BINARY, SHAREDCOL NUMBER)",
resultSet.getString("SPECIFIC_NAME"));
assertThat(
"Columns metadata SPECIFIC_NAME should contains expected columns ",
resultSet
.getString("SPECIFIC_NAME")
.replaceAll("\\s", "")
.matches(
"^FUNC112.*RETURNTABLE.*COLAVARCHAR.*,COLBNUMBER,BIN2BINARY.*,SHAREDCOLNUMBER.?$"));
resultSet.next();
assertEquals("JDBC_DB1", resultSet.getString("FUNCTION_CAT"));
assertEquals("JDBC_SCHEMA11", resultSet.getString("FUNCTION_SCHEM"));
Expand All @@ -217,9 +226,13 @@ public void testGetFunctionColumns() throws SQLException {
databaseMetaData.getMaxBinaryLiteralLength(), resultSet.getInt("CHAR_OCTET_LENGTH"));
assertEquals(3, resultSet.getInt("ORDINAL_POSITION"));
assertEquals("", resultSet.getString("IS_NULLABLE"));
assertEquals(
"FUNC112() RETURN TABLE (COLA VARCHAR, COLB NUMBER, BIN2 BINARY, SHAREDCOL NUMBER)",
resultSet.getString("SPECIFIC_NAME"));
assertThat(
"Columns metadata SPECIFIC_NAME should contains expected columns ",
resultSet
.getString("SPECIFIC_NAME")
.replaceAll("\\s", "")
.matches(
"^FUNC112.*RETURNTABLE.*COLAVARCHAR.*,COLBNUMBER,BIN2BINARY.*,SHAREDCOLNUMBER.?$"));
resultSet.next();
assertEquals("JDBC_DB1", resultSet.getString("FUNCTION_CAT"));
assertEquals("JDBC_SCHEMA11", resultSet.getString("FUNCTION_SCHEM"));
Expand All @@ -237,9 +250,13 @@ public void testGetFunctionColumns() throws SQLException {
assertEquals(0, resultSet.getInt("CHAR_OCTET_LENGTH"));
assertEquals(4, resultSet.getInt("ORDINAL_POSITION"));
assertEquals("", resultSet.getString("IS_NULLABLE"));
assertEquals(
"FUNC112() RETURN TABLE (COLA VARCHAR, COLB NUMBER, BIN2 BINARY, SHAREDCOL NUMBER)",
resultSet.getString("SPECIFIC_NAME"));
assertThat(
"Columns metadata SPECIFIC_NAME should contains expected columns ",
resultSet
.getString("SPECIFIC_NAME")
.replaceAll("\\s", "")
.matches(
"^FUNC112.*RETURNTABLE.*COLAVARCHAR.*,COLBNUMBER,BIN2BINARY.*,SHAREDCOLNUMBER.?$"));
// setting catalog to % will result in 0 columns. % does not apply for catalog, only for
// other
// params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -889,13 +889,16 @@ public void testGetFunctionColumns() throws Exception {
assertEquals(DatabaseMetaData.functionNullableUnknown, resultSet.getInt("NULLABLE"));
assertEquals("returns table of 4 columns", resultSet.getString("REMARKS"));
// char octet length column is not supported and always returns 0
assertEquals(EXPECTED_MAX_CHAR_LENGTH, resultSet.getInt("CHAR_OCTET_LENGTH"));
assertEquals(1, resultSet.getInt("ORDINAL_POSITION"));
// is_nullable column is not supported and always returns empty string
assertEquals("", resultSet.getString("IS_NULLABLE"));
assertEquals(
"FUNC112() RETURN TABLE (COLA VARCHAR, COLB NUMBER, BIN2 BINARY, SHAREDCOL NUMBER)",
resultSet.getString("SPECIFIC_NAME"));
assertThat(
"Columns metadata SPECIFIC_NAME should contains expected columns ",
resultSet
.getString("SPECIFIC_NAME")
.replaceAll("\\s", "")
.matches(
"^FUNC112.*RETURNTABLE.*COLAVARCHAR.*,COLBNUMBER,BIN2BINARY.*,SHAREDCOLNUMBER.?$"));
resultSet.next();
assertEquals(database, resultSet.getString("FUNCTION_CAT"));
assertEquals(schema, resultSet.getString("FUNCTION_SCHEM"));
Expand All @@ -918,9 +921,13 @@ public void testGetFunctionColumns() throws Exception {
assertEquals(2, resultSet.getInt("ORDINAL_POSITION"));
// is_nullable column is not supported and always returns empty string
assertEquals("", resultSet.getString("IS_NULLABLE"));
assertEquals(
"FUNC112() RETURN TABLE (COLA VARCHAR, COLB NUMBER, BIN2 BINARY, SHAREDCOL NUMBER)",
resultSet.getString("SPECIFIC_NAME"));
assertThat(
"Columns metadata SPECIFIC_NAME should contains expected columns ",
resultSet
.getString("SPECIFIC_NAME")
.replaceAll("\\s", "")
.matches(
"^FUNC112.*RETURNTABLE.*COLAVARCHAR.*,COLBNUMBER,BIN2BINARY.*,SHAREDCOLNUMBER.?$"));
resultSet.next();
assertEquals(database, resultSet.getString("FUNCTION_CAT"));
assertEquals(schema, resultSet.getString("FUNCTION_SCHEM"));
Expand All @@ -939,13 +946,16 @@ public void testGetFunctionColumns() throws Exception {
assertEquals(DatabaseMetaData.functionNullableUnknown, resultSet.getInt("NULLABLE"));
assertEquals("returns table of 4 columns", resultSet.getString("REMARKS"));
// char octet length column is not supported and always returns 0
assertEquals(EXPECTED_MAX_BINARY_LENGTH, resultSet.getInt("CHAR_OCTET_LENGTH"));
assertEquals(3, resultSet.getInt("ORDINAL_POSITION"));
// is_nullable column is not supported and always returns empty string
assertEquals("", resultSet.getString("IS_NULLABLE"));
assertEquals(
"FUNC112() RETURN TABLE (COLA VARCHAR, COLB NUMBER, BIN2 BINARY, SHAREDCOL NUMBER)",
resultSet.getString("SPECIFIC_NAME"));
assertThat(
"Columns metadata SPECIFIC_NAME should contains expected columns ",
resultSet
.getString("SPECIFIC_NAME")
.replaceAll("\\s", "")
.matches(
"^FUNC112.*RETURNTABLE.*COLAVARCHAR.*,COLBNUMBER,BIN2BINARY.*,SHAREDCOLNUMBER.?$"));
resultSet.next();
assertEquals(database, resultSet.getString("FUNCTION_CAT"));
assertEquals(schema, resultSet.getString("FUNCTION_SCHEM"));
Expand All @@ -968,9 +978,13 @@ public void testGetFunctionColumns() throws Exception {
assertEquals(4, resultSet.getInt("ORDINAL_POSITION"));
// is_nullable column is not supported and always returns empty string
assertEquals("", resultSet.getString("IS_NULLABLE"));
assertEquals(
"FUNC112() RETURN TABLE (COLA VARCHAR, COLB NUMBER, BIN2 BINARY, SHAREDCOL NUMBER)",
resultSet.getString("SPECIFIC_NAME"));
assertThat(
"Columns metadata SPECIFIC_NAME should contains expected columns ",
resultSet
.getString("SPECIFIC_NAME")
.replaceAll("\\s", "")
.matches(
"^FUNC112.*RETURNTABLE.*COLAVARCHAR.*,COLBNUMBER,BIN2BINARY.*,SHAREDCOLNUMBER.?$"));
assertFalse(resultSet.next());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;
import net.snowflake.client.annotations.DontRunOnJenkins;
import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.ObjectMapperFactory;
import net.snowflake.client.core.UUIDUtils;
Expand Down Expand Up @@ -132,6 +133,7 @@ public static void tearDown() throws SQLException {

@ParameterizedTest
@ArgumentsSource(DataProvider.class)
@DontRunOnJenkins // the MxLobParameters isn't configured properly on new environment
public void testStandardInsertAndSelectWithMaxLobSizeEnabled(int lobSize, String resultFormat)
throws SQLException {
try (Connection con = BaseJDBCTest.getConnection();
Expand All @@ -154,6 +156,7 @@ public void testStandardInsertAndSelectWithMaxLobSizeEnabled(int lobSize, String

@ParameterizedTest
@ArgumentsSource(DataProvider.class)
@DontRunOnJenkins // the MxLobParameters isn't configured properly on new environment
public void testPreparedInsertWithMaxLobSizeEnabled(int lobSize, String resultFormat)
throws SQLException {
try (Connection con = BaseJDBCTest.getConnection();
Expand All @@ -176,6 +179,7 @@ public void testPreparedInsertWithMaxLobSizeEnabled(int lobSize, String resultFo

@ParameterizedTest
@ArgumentsSource(DataProvider.class)
@DontRunOnJenkins // the MxLobParameters isn't configured properly on new environment
public void testPutAndGet(int lobSize, String resultFormat) throws IOException, SQLException {
File tempFile = File.createTempFile("LobSizeTest", ".csv");
// Delete file when JVM shuts down
Expand Down
Loading