|
2 | 2 | from concurrent.futures import ThreadPoolExecutor |
3 | 3 |
|
4 | 4 | import pytest |
5 | | -import sqlalchemy |
6 | 5 | from confluent_kafka import Producer |
7 | 6 |
|
8 | 7 | from tests.util import invoke_ingest_command |
| 8 | +from tests.util.db import get_query_result |
9 | 9 | from tests.warehouse.settings import DESTINATIONS |
10 | 10 |
|
11 | 11 | # Marked explicitly (not auto-marked by path) because this module lives outside tests/warehouse. |
@@ -43,13 +43,10 @@ def run(): |
43 | 43 | assert res.exit_code == 0 |
44 | 44 |
|
45 | 45 | def get_output_table(): |
46 | | - dest_engine = sqlalchemy.create_engine(dest_uri) |
47 | | - with dest_engine.connect() as conn: |
48 | | - res = conn.exec_driver_sql( |
49 | | - f"select _kafka__data from {topic}.output order by _kafka_msg_id asc" |
50 | | - ).fetchall() |
51 | | - dest_engine.dispose() |
52 | | - return res |
| 46 | + return get_query_result( |
| 47 | + dest_uri, |
| 48 | + f"select _kafka__data from {topic}.output order by _kafka_msg_id asc", |
| 49 | + ) |
53 | 50 |
|
54 | 51 | run() |
55 | 52 |
|
@@ -118,17 +115,11 @@ def run(): |
118 | 115 | assert res.exit_code == 0 |
119 | 116 |
|
120 | 117 | def get_output_table(): |
121 | | - dest_engine = sqlalchemy.create_engine(dest_uri) |
122 | | - with dest_engine.connect() as conn: |
123 | | - res = ( |
124 | | - conn.exec_driver_sql( # ty: ignore[no-matching-overload, unused-ignore-comment, unused-ignore-comment] |
125 | | - f"SELECT id, temperature, humidity FROM {topic}.output WHERE temperature >= 38.00 ORDER BY id ASC" |
126 | | - ) |
127 | | - .mappings() |
128 | | - .fetchall() |
129 | | - ) |
130 | | - dest_engine.dispose() |
131 | | - return res |
| 118 | + return get_query_result( |
| 119 | + dest_uri, |
| 120 | + f"SELECT id, temperature, humidity FROM {topic}.output WHERE temperature >= 38.00 ORDER BY id ASC", |
| 121 | + mappings=True, |
| 122 | + ) |
132 | 123 |
|
133 | 124 | run() |
134 | 125 |
|
@@ -174,17 +165,11 @@ def run(): |
174 | 165 | assert res.exit_code == 0 |
175 | 166 |
|
176 | 167 | def get_output_table(): |
177 | | - dest_engine = sqlalchemy.create_engine(dest_uri) |
178 | | - with dest_engine.connect() as conn: |
179 | | - res = ( |
180 | | - conn.exec_driver_sql( |
181 | | - f'SELECT "partition", "topic", "key", "offset" FROM {topic}.output ORDER BY "partition" ASC, "offset" ASC' |
182 | | - ) |
183 | | - .mappings() |
184 | | - .fetchall() |
185 | | - ) |
186 | | - dest_engine.dispose() |
187 | | - return res |
| 168 | + return get_query_result( |
| 169 | + dest_uri, |
| 170 | + f'SELECT "partition", "topic", "key", "offset" FROM {topic}.output ORDER BY "partition" ASC, "offset" ASC', |
| 171 | + mappings=True, |
| 172 | + ) |
188 | 173 |
|
189 | 174 | run() |
190 | 175 |
|
|
0 commit comments