From 90405855b18db769a32d78c9afe9a162041e561e Mon Sep 17 00:00:00 2001 From: cutoutsy Date: Mon, 27 Oct 2025 18:13:08 +0800 Subject: [PATCH] feat(trino): Optimize SQL entity handling without creating temporary tables Signed-off-by: cutoutsy --- .../offline_stores/contrib/trino_offline_store/trino.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/python/feast/infra/offline_stores/contrib/trino_offline_store/trino.py b/sdk/python/feast/infra/offline_stores/contrib/trino_offline_store/trino.py index fd126e87db6..aa4cb2c8a60 100644 --- a/sdk/python/feast/infra/offline_stores/contrib/trino_offline_store/trino.py +++ b/sdk/python/feast/infra/offline_stores/contrib/trino_offline_store/trino.py @@ -372,6 +372,8 @@ def get_historical_features( ) # Generate the Trino SQL query from the query context + if type(entity_df) is str: + table_reference = f"({entity_df})" query = offline_utils.build_point_in_time_query( query_context, left_table_query_string=table_reference, @@ -454,9 +456,7 @@ def _upload_entity_df_and_get_entity_schema( ) -> Dict[str, np.dtype]: """Uploads a Pandas entity dataframe into a Trino table and returns the resulting table""" if type(entity_df) is str: - client.execute_query(f"CREATE TABLE {table_name} AS ({entity_df})") - - results = client.execute_query(f"SELECT * FROM {table_name} LIMIT 1") + results = client.execute_query(f"SELECT * FROM ({entity_df}) LIMIT 1") limited_entity_df = pd.DataFrame( data=results.data, columns=results.columns_names