Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(trino): Optimize SQL entity handling without creating temporary …
…tables

Signed-off-by: cutoutsy <cutoutsy@gmail.com>
  • Loading branch information
cutoutsy committed Oct 27, 2025
commit 90405855b18db769a32d78c9afe9a162041e561e
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down