Skip to content

Commit aa2c838

Browse files
authored
feat: Optimize SQL entity handling without creating temporary tables (#5695)
feat(trino): Optimize SQL entity handling without creating temporary tables Signed-off-by: cutoutsy <[email protected]>
1 parent cc2a46d commit aa2c838

File tree

1 file changed

+3
-3
lines changed
  • sdk/python/feast/infra/offline_stores/contrib/trino_offline_store

1 file changed

+3
-3
lines changed

sdk/python/feast/infra/offline_stores/contrib/trino_offline_store/trino.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ def get_historical_features(
372372
)
373373

374374
# Generate the Trino SQL query from the query context
375+
if type(entity_df) is str:
376+
table_reference = f"({entity_df})"
375377
query = offline_utils.build_point_in_time_query(
376378
query_context,
377379
left_table_query_string=table_reference,
@@ -454,9 +456,7 @@ def _upload_entity_df_and_get_entity_schema(
454456
) -> Dict[str, np.dtype]:
455457
"""Uploads a Pandas entity dataframe into a Trino table and returns the resulting table"""
456458
if type(entity_df) is str:
457-
client.execute_query(f"CREATE TABLE {table_name} AS ({entity_df})")
458-
459-
results = client.execute_query(f"SELECT * FROM {table_name} LIMIT 1")
459+
results = client.execute_query(f"SELECT * FROM ({entity_df}) LIMIT 1")
460460

461461
limited_entity_df = pd.DataFrame(
462462
data=results.data, columns=results.columns_names

0 commit comments

Comments
 (0)