Skip to content

Commit

Permalink
SNOW-1782852: Testing arrow too many rows
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dprzybysz committed Nov 5, 2024
1 parent fd0ddd5 commit 5fc9c8c
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@
*/
package net.snowflake.client.jdbc;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;

import net.snowflake.client.category.TestCategoryArrow;
import org.apache.arrow.flatbuf.Int;
import org.junit.Test;
import org.junit.experimental.categories.Category;

/**
Expand All @@ -15,4 +26,31 @@ public class ResultSetArrowLatestIT extends ResultSetLatestIT {
public ResultSetArrowLatestIT() {
super("arrow");
}

// TODO move to parent - for now we only want to test ARROW
@Test
public void testChunkedResultSetHasExpectedNumberOfRows() throws SQLException {
int rowsToGet = 8295305;
int count = 0;
int seq8 = -1;
Map<Integer, Integer> seq8Usages = new HashMap<>();
try (Statement statement = connection.createStatement();
ResultSet resultSet =
statement.executeQuery(
"select randstr(abs(mod(random(), 20)) + 1 ,random()), seq8() as s from table(generator(rowcount=>"
+ rowsToGet
+ ")) where 1=1 and s > -1 "
+ "order by s")) {
while (resultSet.next()) {
int newSeq8 = resultSet.getInt(2);
// System.out.println(newSeq8 + ": " + resultSet.getString(1));
count++;
assertTrue(seq8 < newSeq8);
seq8 = newSeq8;
seq8Usages.put(newSeq8, seq8Usages.getOrDefault(newSeq8, 0));
}
assertEquals(rowsToGet, count);
assertEquals(rowsToGet, seq8Usages.size());
}
}
}

0 comments on commit 5fc9c8c

Please sign in to comment.