Skip to content

Commit 3ba5558

Browse files
n0g0791dharmisha
authored andcommitted
Fixing issue feast-dev#4688
1 parent 44a4889 commit 3ba5558

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎sdk/python/feast/infra/offline_stores/bigquery.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ def arrow_schema_to_bq_schema(arrow_schema: pyarrow.Schema) -> List[SchemaField]
901901
{{ featureview.created_timestamp_column ~ ' as created_timestamp,' if featureview.created_timestamp_column else '' }}
902902
{{ featureview.entity_selections | join(', ')}}{% if featureview.entity_selections %},{% else %}{% endif %}
903903
{% for feature in featureview.features %}
904-
{{ feature }} as {% if full_feature_names %}{{ featureview.name }}__{{featureview.field_mapping.get(feature, feature)}}{% else %}{{ featureview.field_mapping.get(feature, feature) }}{% endif %}{% if loop.last %}{% else %}, {% endif %}
904+
{{ feature | backticks }} as {% if full_feature_names %}{{ featureview.name }}__{{featureview.field_mapping.get(feature, feature)}}{% else %}{{ featureview.field_mapping.get(feature, feature) | backticks }}{% endif %}{% if loop.last %}{% else %}, {% endif %}
905905
{% endfor %}
906906
FROM {{ featureview.table_subquery }}
907907
WHERE {{ featureview.timestamp_field }} <= '{{ featureview.max_event_timestamp }}'
@@ -995,14 +995,14 @@ def arrow_schema_to_bq_schema(arrow_schema: pyarrow.Schema) -> List[SchemaField]
995995
The entity_dataframe dataset being our source of truth here.
996996
*/
997997
998-
SELECT {{ final_output_feature_names | join(', ')}}
998+
SELECT {{ final_output_feature_names | backticks | join(', ')}}
999999
FROM entity_dataframe
10001000
{% for featureview in featureviews %}
10011001
LEFT JOIN (
10021002
SELECT
10031003
{{featureview.name}}__entity_row_unique_id
10041004
{% for feature in featureview.features %}
1005-
,{% if full_feature_names %}{{ featureview.name }}__{{featureview.field_mapping.get(feature, feature)}}{% else %}{{ featureview.field_mapping.get(feature, feature) }}{% endif %}
1005+
,{% if full_feature_names %}{{ featureview.name }}__{{featureview.field_mapping.get(feature, feature)}}{% else %}{{ featureview.field_mapping.get(feature, feature) | backticks }}{% endif %}
10061006
{% endfor %}
10071007
FROM {{ featureview.name }}__cleaned
10081008
) USING ({{featureview.name}}__entity_row_unique_id)

‎sdk/python/feast/infra/offline_stores/offline_utils.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ def build_point_in_time_query(
186186
full_feature_names: bool = False,
187187
) -> str:
188188
"""Build point-in-time query between each feature view table and the entity dataframe for Bigquery and Redshift"""
189-
template = Environment(loader=BaseLoader()).from_string(source=query_template)
189+
env = Environment(loader=BaseLoader())
190+
env.filters['backticks'] = enclose_in_backticks
191+
template = env.from_string(source=query_template)
190192

191193
final_output_feature_names = list(entity_df_columns)
192194
final_output_feature_names.extend(
@@ -252,3 +254,11 @@ def get_pyarrow_schema_from_batch_source(
252254
column_names.append(column_name)
253255

254256
return pa.schema(pa_schema), column_names
257+
258+
259+
def enclose_in_backticks(value):
260+
# Check if the input is a list
261+
if isinstance(value, list):
262+
return [f'`{v}`' for v in value]
263+
else:
264+
return f'`{value}`'

0 commit comments

Comments
 (0)