Skip to content

Commit e8eae71

Browse files
authored
fix: Column quoting in query of PostgreSQLOfflineStore.pull_all_from_table_or_query (#5621)
* Fix column quoting issue in query in `PostgreSQLOfflineStore.pull_all_from_table_or_query` Signed-off-by: Hung Nguyen <[email protected]> * fix: failing test due to changes in expected query Signed-off-by: Hung Nguyen <[email protected]> --------- Signed-off-by: Hung Nguyen <[email protected]>
1 parent d56baf4 commit e8eae71

File tree

2 files changed

+5
-2
lines changed
  • sdk/python
    • feast/infra/offline_stores/contrib/postgres_offline_store
    • tests/unit/infra/offline_stores/contrib/postgres_offline_store

2 files changed

+5
-2
lines changed

sdk/python/feast/infra/offline_stores/contrib/postgres_offline_store/postgres.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ def pull_all_from_table_or_query(
280280
if created_timestamp_column:
281281
timestamp_fields.append(created_timestamp_column)
282282
field_string = ", ".join(
283-
join_key_columns + feature_name_columns + timestamp_fields
283+
_append_alias(
284+
join_key_columns + feature_name_columns + timestamp_fields,
285+
"paftoq_alias",
286+
)
284287
)
285288

286289
timestamp_filter = get_timestamp_filter_sql(

sdk/python/tests/unit/infra/offline_stores/contrib/postgres_offline_store/test_postgres.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def test_pull_all_from_table_or_query(mock_get_conn):
184184
actual_query = retrieval_job.to_sql().strip()
185185
logger.debug("Actual query:\n%s", actual_query)
186186

187-
expected_query = """SELECT key1, key2, feature1, feature2, event_published_datetime_utc
187+
expected_query = """SELECT paftoq_alias."key1", paftoq_alias."key2", paftoq_alias."feature1", paftoq_alias."feature2", paftoq_alias."event_published_datetime_utc"
188188
FROM offline_store_database_name.offline_store_table_name AS paftoq_alias
189189
WHERE "event_published_datetime_utc" BETWEEN '2021-01-01 00:00:00+00:00'::timestamptz AND '2021-01-02 00:00:00+00:00'::timestamptz""" # noqa: W293
190190

0 commit comments

Comments
 (0)