Skip to content

Commit 16c0e40

Browse files
committed
test(integration): align arrow scenarios with prod behavior
1 parent 9e32d72 commit 16c0e40

2 files changed

Lines changed: 20 additions & 37 deletions

File tree

‎tests/integration/test_managed_tables_lifecycle.py‎

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@
55
66
1. declare a schema and a table on the database's default catalog connection,
77
2. upload a small parquet file,
8-
3. load it into the table (load_managed_table),
9-
4. poll get_table_profile until the load syncs,
10-
5. purge_table_cache,
11-
6. delete the managed table.
8+
3. load it into the table (load_managed_table) and verify the load response,
9+
4. purge_table_cache,
10+
5. delete the managed table.
1211
13-
Note on managed-catalog semantics: there is no `refresh` step. `refresh` is
14-
rejected with a 400 on a managed catalog ("use the loads endpoint to update its
15-
data") — `load_managed_table` is itself the load. The profile is populated
16-
asynchronously after the load, so step 4 polls get_table_profile (a 404 means
17-
"not synced yet") rather than reading it once.
12+
Notes on managed-catalog semantics (both confirmed against prod):
13+
14+
* There is no `refresh` step. `refresh` is rejected with a 400 on a managed
15+
catalog ("use the loads endpoint to update its data") — `load_managed_table`
16+
is itself the load.
17+
* There is no `get_table_profile` step. The profile is not populated within a
18+
usable window after a load, and no API call (refresh is rejected; there is
19+
no profile-build/scan endpoint) triggers it — so the load is verified via
20+
the `load_managed_table` response (row_count etc.), not a profile read.
1821
1922
The scratch_database fixture tears the database (and its catalog) down, so the
2023
test touches no seeded data. pyarrow is a hard test dependency (see
@@ -25,24 +28,18 @@
2528
from __future__ import annotations
2629

2730
import io
28-
import time
2931

3032
import pyarrow as pa
3133
import pyarrow.parquet as pq
3234

3335
from hotdata.api.connections_api import ConnectionsApi
3436
from hotdata.api.databases_api import DatabasesApi
3537
from hotdata.api.uploads_api import UploadsApi
36-
from hotdata.exceptions import ApiException
3738
from hotdata.models.add_managed_schema_request import AddManagedSchemaRequest
3839
from hotdata.models.add_managed_table_request import AddManagedTableRequest
3940
from hotdata.models.load_managed_table_request import LoadManagedTableRequest
4041

4142

42-
PROFILE_SYNC_TIMEOUT_S = 60.0
43-
PROFILE_POLL_INTERVAL_S = 2.0
44-
45-
4643
def _parquet_bytes() -> bytes:
4744
table = pa.table({"x": [1, 2, 3], "msg": ["a", "b", "c"]})
4845
buf = io.BytesIO()
@@ -84,27 +81,6 @@ def test_managed_tables_lifecycle(
8481
assert loaded.table_name == table_name
8582
assert loaded.row_count == 3
8683

87-
# The profile syncs asynchronously after the load — get_table_profile 404s
88-
# ("Table may not be synced yet") until it lands. Poll instead of reading
89-
# once. There is no manual trigger to force this: refresh is rejected on a
90-
# managed catalog, and load_managed_table is the load.
91-
deadline = time.monotonic() + PROFILE_SYNC_TIMEOUT_S
92-
profile = None
93-
while time.monotonic() < deadline:
94-
try:
95-
profile = connections_api.get_table_profile(
96-
connection_id, schema_name, table_name
97-
)
98-
break
99-
except ApiException as exc:
100-
if exc.status != 404:
101-
raise
102-
time.sleep(PROFILE_POLL_INTERVAL_S)
103-
assert profile is not None, "table profile never synced after load"
104-
assert profile.var_schema == schema_name
105-
assert profile.table == table_name
106-
assert profile.row_count == 3
107-
10884
# purge_table_cache and delete_managed_table both return None on success.
10985
connections_api.purge_table_cache(connection_id, schema_name, table_name)
11086
connections_api.delete_managed_table(connection_id, schema_name, table_name)

‎tests/integration/test_results_arrow.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,14 @@ def test_results_arrow(
5353
QueryRequest(
5454
var_async=True,
5555
async_after_ms=1000,
56-
sql="SELECT 1 AS x, 'hello' AS msg UNION ALL SELECT 2, 'world'",
56+
# ORDER BY so row order is deterministic — UNION ALL alone does not
57+
# guarantee it, and the column/pagination asserts below depend on it.
58+
sql=(
59+
"SELECT x, msg FROM ("
60+
"SELECT 1 AS x, 'hello' AS msg "
61+
"UNION ALL SELECT 2, 'world'"
62+
") ORDER BY x"
63+
),
5764
),
5865
x_database_id=database_id,
5966
)

0 commit comments

Comments
 (0)