Skip to content

Commit 043d82a

Browse files
authored
Merge pull request #339 from databricks/large-test
Add large query integration test to E2E tests
2 parents 28989f7 + 89c94e6 commit 043d82a

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 = "SELECT * FROM range(37500000)"; // ~300MB of data
16+
ResultSet rs = executeQuery(largeQuerySQL);
17+
int rows = 0;
18+
while (rs != null && rs.next()) {
19+
rows++;
20+
}
21+
assertEquals(37500000, rows, "Expected 37500000 rows, got " + rows);
22+
}
23+
24+
@Test
25+
void testQueryYieldingLargeWideResultSet() throws SQLException {
26+
int resultSize = 300 * 1000 * 100; // 30 MB
27+
int width = 8192; // B
28+
int rows = resultSize / width;
29+
int cols = width / 36;
30+
31+
// Generate the UUID columns
32+
String uuids =
33+
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+
ResultSet rs = executeQuery(query);
40+
int rowCount = 0;
41+
while (rs != null && rs.next()) {
42+
assertEquals(rs.getInt("id"), rowCount, "Expected id to be equal to row number");
43+
assertEquals(rs.getString("uuid0").length(), 36, "Expected UUID length of 36");
44+
rowCount++;
45+
}
46+
assertEquals(rows, rowCount, "Expected " + rows + " rows, got " + rowCount);
47+
}
48+
}

0 commit comments

Comments
 (0)