CI Fix - Athena CI Failing Sometimes
AI Notes
Link: https://github.com/SQLMesh/sqlmesh/actions/runs/32524629055/job/96906313004
Failing test
tests/core/engine_adapter/integration/test_integration_athena.py::test_clear_partition_data
What’s Wrong Test assumes the S3 folder starts empty. A earlier attempt already wrote files there (plan failed with src_table not found — typical Athena/Glue lag), Hive DROP TABLE does not delete S3 files, and the rerun hits leftover objects → assert 3 == 0. This is a flaky/cleanup test issue, not clear-partition logic itself.
Possible Fix
In test_integration_athena.py: clear the S3 prefix at the start (or on teardown/retry) instead of requiring it empty. Optionally wait/retry until src_table is visible after CTAS before planning.
Hi! I would like to work on this one
Confirmed the root cause by checking the linked CI run, the failure is AssertionError: assert 3 == 0 on the precondition check at the top of test_clear_partition_data (assert len(s3_list_objects(s3, base_uri)) == 0), with the leftover objects sitting under src_table/ from a prior (rerun) attempt's ctas. Since DROP TABLE doesn't clean up S3 files, those survive across pytest reruns and trip the next attempt's precondition.
Planning to:
- Actively clear the S3 prefix at the start of the test instead of asserting it's already empty, so reruns are self healing.
- Look at adding a wait/retry for src_table visibility after the CTAS to reduce how often the underlying Glue lag race fires in the first place.
Will open a draft PR shortly