Skip to content
Merged
Changes from all commits
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
18 changes: 15 additions & 3 deletions sdk/python/feast/infra/offline_stores/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ def pull_latest_from_table_or_query(
assert isinstance(data_source, BigQuerySource)
from_expression = data_source.get_table_query_string()

partition_by_join_key_string = ", ".join(join_key_columns)
partition_by_join_key_string = ", ".join(
BigQueryOfflineStore._escape_query_columns(join_key_columns)
)
if partition_by_join_key_string != "":
partition_by_join_key_string = (
"PARTITION BY " + partition_by_join_key_string
Expand All @@ -146,7 +148,11 @@ def pull_latest_from_table_or_query(
if created_timestamp_column:
timestamps.append(created_timestamp_column)
timestamp_desc_string = " DESC, ".join(timestamps) + " DESC"
field_string = ", ".join(join_key_columns + feature_name_columns + timestamps)
field_string = ", ".join(
BigQueryOfflineStore._escape_query_columns(join_key_columns)
+ BigQueryOfflineStore._escape_query_columns(feature_name_columns)
+ timestamps
)
project_id = (
config.offline_store.billing_project_id or config.offline_store.project_id
)
Expand Down Expand Up @@ -196,7 +202,9 @@ def pull_all_from_table_or_query(
location=config.offline_store.location,
)
field_string = ", ".join(
join_key_columns + feature_name_columns + [timestamp_field]
BigQueryOfflineStore._escape_query_columns(join_key_columns)
+ BigQueryOfflineStore._escape_query_columns(feature_name_columns)
+ [timestamp_field]
)
query = f"""
SELECT {field_string}
Expand Down Expand Up @@ -429,6 +437,10 @@ def offline_write_batch(
job_config=job_config,
).result()

@staticmethod
def _escape_query_columns(columns: List[str]) -> List[str]:
return [f"`{x}`" for x in columns]


class BigQueryRetrievalJob(RetrievalJob):
def __init__(
Expand Down