Skip to content

fix(trino): Clean up temporary entity tables after retrieval#6381

Open
Jwrede wants to merge 1 commit intofeast-dev:masterfrom
Jwrede:fix/trino-temp-table-cleanup
Open

fix(trino): Clean up temporary entity tables after retrieval#6381
Jwrede wants to merge 1 commit intofeast-dev:masterfrom
Jwrede:fix/trino-temp-table-cleanup

Conversation

@Jwrede
Copy link
Copy Markdown
Contributor

@Jwrede Jwrede commented May 7, 2026

Summary

TrinoOfflineStore.get_historical_features() creates a temporary table
(feast_entity_df_<uuid>) for the entity DataFrame but never drops it,
leaking tables in the Trino catalog indefinitely.

This applies the same context manager pattern already used by the
BigQuery, Redshift, and Athena offline stores: wrap the query in a
generator that issues DROP TABLE IF EXISTS in a finally block.

The cleanup only runs when the entity_df is a DataFrame (when a temp
table was actually created), not when it is a SQL string.

Fixes #6306

How Has This Been Tested?

  • Verified the change follows the same pattern as BigQuery
    (bigquery.py:304), Redshift (redshift.py:236), and Athena
    (athena.py:224).
  • All callers of TrinoRetrievalJob that pass a plain query string
    (e.g. pull_latest_from_table_or_query) continue to work via the
    fallback contextmanager wrapper.

TrinoOfflineStore.get_historical_features() creates a temporary table
for the entity DataFrame but never drops it, leaking tables
indefinitely. Apply the same context manager pattern used by
BigQuery, Redshift, and Athena offline stores: wrap the query in a
generator that issues DROP TABLE IF EXISTS in a finally block.

Fixes feast-dev#6306

Signed-off-by: Jonathan Wrede <wrede.jonathan00@gmail.com>
@Jwrede Jwrede requested a review from a team as a code owner May 7, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TrinoOfflineStore does not cleanup temporary tables

1 participant