Skip to content

Commit

Permalink
fix: Changing Snowflake template code to avoid query not implemented … (
Browse files Browse the repository at this point in the history
#3319)

fix: Changing Snowflake template code to avoid query not implemented error

Signed-off-by: miles.adkins <miles.adkins@snowflake.com>

Signed-off-by: miles.adkins <miles.adkins@snowflake.com>
  • Loading branch information
sfc-gh-madkins authored Oct 28, 2022
1 parent 0ad0ace commit 1590d6b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sdk/python/feast/templates/snowflake/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from datetime import datetime, timedelta

import pandas as pd
import yaml
from pytz import utc

from feast import FeatureStore
Expand Down Expand Up @@ -76,6 +77,10 @@ def fetch_historical_features_entity_sql(store: FeatureStore, for_batch_scoring)
datetime.now().replace(microsecond=0, second=0, minute=0).astimezone(tz=utc)
)
start_date = (end_date - timedelta(days=60)).astimezone(tz=utc)

project_name = yaml.safe_load(open("feature_repo/feature_store.yaml"))["project"]
table_name = f"{project_name}_feast_driver_hourly_stats"

# For batch scoring, we want the latest timestamps
if for_batch_scoring:
print(
Expand All @@ -86,7 +91,7 @@ def fetch_historical_features_entity_sql(store: FeatureStore, for_batch_scoring)
SELECT
"driver_id",
CURRENT_TIMESTAMP() as "event_timestamp"
FROM {store.list_data_sources()[-1].get_table_query_string()}
FROM {store.get_data_source(table_name).get_table_query_string()}
WHERE "event_timestamp" BETWEEN '{start_date}' AND '{end_date}'
GROUP BY "driver_id"
"""
Expand All @@ -97,7 +102,7 @@ def fetch_historical_features_entity_sql(store: FeatureStore, for_batch_scoring)
SELECT
"driver_id",
"event_timestamp"
FROM {store.list_data_sources()[-1].get_table_query_string()}
FROM {store.get_data_source(table_name).get_table_query_string()}
WHERE "event_timestamp" BETWEEN '{start_date}' AND '{end_date}'
"""

Expand Down

0 comments on commit 1590d6b

Please sign in to comment.