diff --git a/src/test/java/net/snowflake/client/jdbc/SnowflakeResultSetSerializableArrowIT.java b/src/test/java/net/snowflake/client/jdbc/SnowflakeResultSetSerializableArrowIT.java deleted file mode 100644 index 2c69ae2af..000000000 --- a/src/test/java/net/snowflake/client/jdbc/SnowflakeResultSetSerializableArrowIT.java +++ /dev/null @@ -1,13 +0,0 @@ -package net.snowflake.client.jdbc; - -import net.snowflake.client.category.TestTags; -import org.junit.jupiter.api.Tag; - -/** Test SnowflakeResultSetSerializable for Arrow */ -// @Category(TestCategoryArrow.class) -@Tag(TestTags.ARROW) -public class SnowflakeResultSetSerializableArrowIT extends SnowflakeResultSetSerializableIT { - public SnowflakeResultSetSerializableArrowIT() { - super("arrow"); - } -} diff --git a/src/test/java/net/snowflake/client/jdbc/SnowflakeResultSetSerializableIT.java b/src/test/java/net/snowflake/client/jdbc/SnowflakeResultSetSerializableIT.java index 76e9e25dc..31f6435d7 100644 --- a/src/test/java/net/snowflake/client/jdbc/SnowflakeResultSetSerializableIT.java +++ b/src/test/java/net/snowflake/client/jdbc/SnowflakeResultSetSerializableIT.java @@ -21,11 +21,14 @@ import javax.annotation.Nullable; import net.snowflake.client.annotations.DontRunOnGithubActions; import net.snowflake.client.category.TestTags; +import net.snowflake.client.providers.SimpleFormatProvider; import org.hamcrest.MatcherAssert; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ArgumentsSource; /** SnowflakeResultSetSerializable tests */ // @Category(TestCategoryResultSet.class) @@ -35,25 +38,16 @@ public class SnowflakeResultSetSerializableIT extends BaseJDBCTest { private static boolean developPrint = false; - private String queryResultFormat; - // sfFullURL is used to support private link URL. // This test case is not for private link env, so just use a valid URL for testing purpose. private String sfFullURL = "https://sfctest0.snowflakecomputing.com"; - public SnowflakeResultSetSerializableIT() { - this("json"); - } - - SnowflakeResultSetSerializableIT(String format) { - queryResultFormat = format; + public Connection init(String queryResultFormat) throws SQLException { + return init(null, queryResultFormat); } - public Connection init() throws SQLException { - return init(null); - } - - public Connection init(@Nullable Properties properties) throws SQLException { + public Connection init(@Nullable Properties properties, String queryResultFormat) + throws SQLException { Connection conn = BaseJDBCTest.getConnection(properties); try (Statement stmt = conn.createStatement()) { stmt.execute("alter session set jdbc_query_result_format = '" + queryResultFormat + "'"); @@ -237,11 +231,16 @@ private String deserializeResultSetWithProperties(List files, Properties * @throws Throwable If any error happens. */ private void testBasicTableHarness( - int rowCount, long maxSizeInBytes, String whereClause, boolean needSetupTable, boolean async) + int rowCount, + long maxSizeInBytes, + String whereClause, + boolean needSetupTable, + boolean async, + String queryResultFormat) throws Throwable { List fileNameList = null; String originalResultCSVString = null; - try (Connection connection = init()) { + try (Connection connection = init(queryResultFormat)) { Statement statement = connection.createStatement(); if (developPrint) { @@ -288,57 +287,61 @@ private void testBasicTableHarness( assertEquals(chunkResultString, originalResultCSVString); } - @Test + @ParameterizedTest + @ArgumentsSource(SimpleFormatProvider.class) @DontRunOnGithubActions - public void testBasicTableWithEmptyResult() throws Throwable { + public void testBasicTableWithEmptyResult(String queryResultFormat) throws Throwable { // Use complex WHERE clause in order to test both ARROW and JSON. // It looks GS only generates JSON format result. - testBasicTableHarness(10, 1024, "where int_c * int_c = 2", true, false); + testBasicTableHarness(10, 1024, "where int_c * int_c = 2", true, false, queryResultFormat); // Test Async mode - testBasicTableHarness(10, 1024, "where int_c * int_c = 2", true, true); + testBasicTableHarness(10, 1024, "where int_c * int_c = 2", true, true, queryResultFormat); } - @Test + @ParameterizedTest + @ArgumentsSource(SimpleFormatProvider.class) @DontRunOnGithubActions - public void testBasicTableWithOnlyFirstChunk() throws Throwable { + public void testBasicTableWithOnlyFirstChunk(String queryResultFormat) throws Throwable { // Result only includes first data chunk, test maxSize is small. - testBasicTableHarness(1, 1, "", true, false); + testBasicTableHarness(1, 1, "", true, false, queryResultFormat); // Test Async mode - testBasicTableHarness(1, 1, "", true, true); + testBasicTableHarness(1, 1, "", true, true, queryResultFormat); // Result only includes first data chunk, test maxSize is big. - testBasicTableHarness(1, 1024 * 1024, "", false, false); + testBasicTableHarness(1, 1024 * 1024, "", false, false, queryResultFormat); // Test async mode - testBasicTableHarness(1, 1024 * 1024, "", false, true); + testBasicTableHarness(1, 1024 * 1024, "", false, true, queryResultFormat); } - @Test + @ParameterizedTest + @ArgumentsSource(SimpleFormatProvider.class) @DontRunOnGithubActions - public void testBasicTableWithOneFileChunk() throws Throwable { + public void testBasicTableWithOneFileChunk(String queryResultFormat) throws Throwable { // Result only includes first data chunk, test maxSize is small. - testBasicTableHarness(300, 1, "", true, false); + testBasicTableHarness(300, 1, "", true, false, queryResultFormat); // Test Async mode - testBasicTableHarness(300, 1, "", true, true); + testBasicTableHarness(300, 1, "", true, true, queryResultFormat); // Result only includes first data chunk, test maxSize is big. - testBasicTableHarness(300, 1024 * 1024, "", false, false); + testBasicTableHarness(300, 1024 * 1024, "", false, false, queryResultFormat); // Test Async mode - testBasicTableHarness(300, 1024 * 1024, "", false, true); + testBasicTableHarness(300, 1024 * 1024, "", false, true, queryResultFormat); } - @Test + @ParameterizedTest + @ArgumentsSource(SimpleFormatProvider.class) @DontRunOnGithubActions - public void testBasicTableWithSomeFileChunks() throws Throwable { + public void testBasicTableWithSomeFileChunks(String queryResultFormat) throws Throwable { // Result only includes first data chunk, test maxSize is small. - testBasicTableHarness(90000, 1, "", true, false); + testBasicTableHarness(90000, 1, "", true, false, queryResultFormat); // Test Async mode - testBasicTableHarness(90000, 1, "", true, true); + testBasicTableHarness(90000, 1, "", true, true, queryResultFormat); // Result only includes first data chunk, test maxSize is median. - testBasicTableHarness(90000, 3 * 1024 * 1024, "", false, false); + testBasicTableHarness(90000, 3 * 1024 * 1024, "", false, false, queryResultFormat); // Test Async mode - testBasicTableHarness(90000, 3 * 1024 * 1024, "", false, true); + testBasicTableHarness(90000, 3 * 1024 * 1024, "", false, true, queryResultFormat); // Result only includes first data chunk, test maxSize is big. - testBasicTableHarness(90000, 100 * 1024 * 1024, "", false, false); + testBasicTableHarness(90000, 100 * 1024 * 1024, "", false, false, queryResultFormat); // Test Async mode - testBasicTableHarness(90000, 100 * 1024 * 1024, "", false, true); + testBasicTableHarness(90000, 100 * 1024 * 1024, "", false, true, queryResultFormat); } /** @@ -364,11 +367,12 @@ private void testTimestampHarness( String format_ntz, String format_ltz, String format_tz, - String timezone) + String timezone, + String queryResultFormat) throws Throwable { List fileNameList = null; String originalResultCSVString = null; - try (Connection connection = init(); + try (Connection connection = init(queryResultFormat); Statement statement = connection.createStatement()) { statement.execute("alter session set DATE_OUTPUT_FORMAT = '" + format_date + "'"); statement.execute("alter session set TIME_OUTPUT_FORMAT = '" + format_time + "'"); @@ -418,9 +422,10 @@ private void testTimestampHarness( assertEquals(chunkResultString, originalResultCSVString); } - @Test + @ParameterizedTest + @ArgumentsSource(SimpleFormatProvider.class) @DontRunOnGithubActions - public void testTimestamp() throws Throwable { + public void testTimestamp(String queryResultFormat) throws Throwable { String[] dateFormats = {"YYYY-MM-DD", "DD-MON-YYYY", "MM/DD/YYYY"}; String[] timeFormats = {"HH24:MI:SS.FFTZH:TZM", "HH24:MI:SS.FF", "HH24:MI:SS"}; String[] timestampFormats = { @@ -440,16 +445,19 @@ public void testTimestamp() throws Throwable { timestampFormats[i], timestampFormats[i], timestampFormats[i], - timezones[i]); + timezones[i], + queryResultFormat); } } - @Test + @ParameterizedTest + @ArgumentsSource(SimpleFormatProvider.class) @DontRunOnGithubActions - public void testBasicTableWithSerializeObjectsAfterReadResultSet() throws Throwable { + public void testBasicTableWithSerializeObjectsAfterReadResultSet(String queryResultFormat) + throws Throwable { List fileNameList = null; String originalResultCSVString = null; - try (Connection connection = init(); + try (Connection connection = init(queryResultFormat); Statement statement = connection.createStatement()) { statement.execute("create or replace schema testschema"); @@ -527,13 +535,14 @@ private synchronized List splitResultSetSerializables( return resultFileList; } - @Test + @ParameterizedTest + @ArgumentsSource(SimpleFormatProvider.class) @DontRunOnGithubActions - public void testSplitResultSetSerializable() throws Throwable { + public void testSplitResultSetSerializable(String queryResultFormat) throws Throwable { List fileNameList = null; String originalResultCSVString = null; int rowCount = 90000; - try (Connection connection = init(); + try (Connection connection = init(queryResultFormat); Statement statement = connection.createStatement()) { statement.execute( @@ -593,10 +602,11 @@ private void hackToSetupWrongURL(List resultSetS } } - @Test + @ParameterizedTest + @ArgumentsSource(SimpleFormatProvider.class) @DontRunOnGithubActions - public void testCloseUnconsumedResultSet() throws Throwable { - try (Connection connection = init(); + public void testCloseUnconsumedResultSet(String queryResultFormat) throws Throwable { + try (Connection connection = init(queryResultFormat); Statement statement = connection.createStatement()) { try { statement.execute( @@ -623,13 +633,14 @@ public void testCloseUnconsumedResultSet() throws Throwable { } } - @Test + @ParameterizedTest + @ArgumentsSource(SimpleFormatProvider.class) @DontRunOnGithubActions - public void testNegativeWithChunkFileNotExist() throws Throwable { + public void testNegativeWithChunkFileNotExist(String queryResultFormat) throws Throwable { // This test takes about (download worker retry times * networkTimeout) long to finish Properties properties = new Properties(); properties.put("networkTimeout", 10000); // 10000 millisec - try (Connection connection = init(properties)) { + try (Connection connection = init(properties, queryResultFormat)) { try (Statement statement = connection.createStatement()) { statement.execute( "create or replace table table_basic " + " (int_c int, string_c string(128))"); @@ -677,10 +688,11 @@ public void testNegativeWithChunkFileNotExist() throws Throwable { } } - @Test + @ParameterizedTest + @ArgumentsSource(SimpleFormatProvider.class) @DontRunOnGithubActions - public void testNegativeWithClosedResultSet() throws Throwable { - try (Connection connection = init()) { + public void testNegativeWithClosedResultSet(String queryResultFormat) throws Throwable { + try (Connection connection = init(queryResultFormat)) { Statement statement = connection.createStatement(); statement.execute( @@ -729,15 +741,16 @@ public void testNegativeWithClosedResultSet() throws Throwable { * * @throws Throwable */ - @Test + @ParameterizedTest + @ArgumentsSource(SimpleFormatProvider.class) @Disabled @DontRunOnGithubActions - public void testCustomProxyWithFiles() throws Throwable { + public void testCustomProxyWithFiles(String queryResultFormat) throws Throwable { boolean generateFiles = false; boolean correctProxy = false; if (generateFiles) { - generateTestFiles(); + generateTestFiles(queryResultFormat); fail("This is generate test file."); } @@ -774,8 +787,8 @@ public void testCustomProxyWithFiles() throws Throwable { } } - private void generateTestFiles() throws Throwable { - try (Connection connection = init(); + private void generateTestFiles(String queryResultFormat) throws Throwable { + try (Connection connection = init(queryResultFormat); Statement statement = connection.createStatement()) { statement.execute( @@ -799,15 +812,16 @@ private void generateTestFiles() throws Throwable { } } - @Test + @ParameterizedTest + @ArgumentsSource(SimpleFormatProvider.class) @DontRunOnGithubActions - public void testRetrieveMetadata() throws Throwable { + public void testRetrieveMetadata(String queryResultFormat) throws Throwable { List fileNameList; int rowCount = 90000; long expectedTotalRowCount = 0; long expectedTotalCompressedSize = 0; long expectedTotalUncompressedSize = 0; - try (Connection connection = init(); + try (Connection connection = init(queryResultFormat); Statement statement = connection.createStatement()) { statement.execute(