|
5 | 5 |
|
6 | 6 | 1. declare a schema and a table on the database's default catalog connection, |
7 | 7 | 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. |
12 | 11 |
|
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. |
18 | 21 |
|
19 | 22 | The scratch_database fixture tears the database (and its catalog) down, so the |
20 | 23 | test touches no seeded data. pyarrow is a hard test dependency (see |
|
25 | 28 | from __future__ import annotations |
26 | 29 |
|
27 | 30 | import io |
28 | | -import time |
29 | 31 |
|
30 | 32 | import pyarrow as pa |
31 | 33 | import pyarrow.parquet as pq |
32 | 34 |
|
33 | 35 | from hotdata.api.connections_api import ConnectionsApi |
34 | 36 | from hotdata.api.databases_api import DatabasesApi |
35 | 37 | from hotdata.api.uploads_api import UploadsApi |
36 | | -from hotdata.exceptions import ApiException |
37 | 38 | from hotdata.models.add_managed_schema_request import AddManagedSchemaRequest |
38 | 39 | from hotdata.models.add_managed_table_request import AddManagedTableRequest |
39 | 40 | from hotdata.models.load_managed_table_request import LoadManagedTableRequest |
40 | 41 |
|
41 | 42 |
|
42 | | -PROFILE_SYNC_TIMEOUT_S = 60.0 |
43 | | -PROFILE_POLL_INTERVAL_S = 2.0 |
44 | | - |
45 | | - |
46 | 43 | def _parquet_bytes() -> bytes: |
47 | 44 | table = pa.table({"x": [1, 2, 3], "msg": ["a", "b", "c"]}) |
48 | 45 | buf = io.BytesIO() |
@@ -84,27 +81,6 @@ def test_managed_tables_lifecycle( |
84 | 81 | assert loaded.table_name == table_name |
85 | 82 | assert loaded.row_count == 3 |
86 | 83 |
|
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 | | - |
108 | 84 | # purge_table_cache and delete_managed_table both return None on success. |
109 | 85 | connections_api.purge_table_cache(connection_id, schema_name, table_name) |
110 | 86 | connections_api.delete_managed_table(connection_id, schema_name, table_name) |
0 commit comments