Skip to content

Commit a666de9

Browse files
committed
Add large query integration test
1 parent 82957ee commit a666de9

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.databricks.jdbc.integration.e2e;
2+
3+
import static com.databricks.jdbc.integration.IntegrationTestUtil.*;
4+
import static org.junit.jupiter.api.Assertions.*;
5+
6+
import java.sql.ResultSet;
7+
import java.sql.SQLException;
8+
import java.util.stream.Collectors;
9+
import java.util.stream.IntStream;
10+
import org.junit.jupiter.api.Test;
11+
12+
public class LargeQueryExecutionTests {
13+
@Test
14+
void testQueryYieldingLargeNarrowResultSet() throws SQLException {
15+
String largeQuerySQL =
16+
"SELECT * FROM range(37500000)"; // ~300MB of data
17+
ResultSet rs = executeQuery(largeQuerySQL);
18+
int rows = 0;
19+
while (rs != null && rs.next()) {
20+
rows++;
21+
}
22+
assertEquals(37500000, rows, "Expected 37500000 rows, got " + rows);
23+
}
24+
25+
@Test
26+
void testQueryYieldingLargeWideResultSet() throws SQLException {
27+
int resultSize = 300 * 1000 * 100; // 30 MB
28+
int width = 8192; // B
29+
int rows = resultSize / width;
30+
int cols = width / 36;
31+
32+
// Generate the UUID columns
33+
String uuids = IntStream.rangeClosed(0, cols)
34+
.mapToObj(i -> "uuid() uuid" + i)
35+
.collect(Collectors.joining(", "));
36+
37+
// Create the SQL query
38+
String query = String.format("SELECT id, %s FROM RANGE(%d)", uuids, rows);
39+
System.out.println("query: " + query);
40+
ResultSet rs = executeQuery(query);
41+
int rowCount = 0;
42+
while (rs != null && rs.next()) {
43+
System.out.println("check");
44+
assertEquals(rs.getInt("id"), rowCount, "Expected id to be equal to row number");
45+
assertEquals(rs.getString("uuid0").length(), 36, "Expected UUID length of 36");
46+
rowCount++;
47+
}
48+
assertEquals(rows, rowCount, "Expected " + rows + " rows, got " + rowCount);
49+
}
50+
}

0 commit comments

Comments
 (0)