Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Snowflake skip materialization if no table change #3404

Merged
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
13 changes: 13 additions & 0 deletions sdk/python/feast/infra/materialization/snowflake_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pandas as pd
from colorama import Fore, Style
from pydantic import Field, StrictStr
from pytz import utc
from tqdm import tqdm

import feast
Expand Down Expand Up @@ -256,6 +257,18 @@ def _materialize_one(
end_date=end_date,
)

# Lets check and see if we can skip this query, because the table hasnt changed
# since before the start date of this query
with get_snowflake_conn(self.repo_config.offline_store) as conn:
query = f"""SELECT SYSTEM$LAST_CHANGE_COMMIT_TIME('{feature_view.batch_source.get_table_query_string()}') AS last_commit_change_time"""
last_commit_change_time = (
conn.cursor().execute(query).fetchall()[0][0] / 1_000_000_000
)
if last_commit_change_time < start_date.astimezone(tz=utc).timestamp():
return SnowflakeMaterializationJob(
job_id=job_id, status=MaterializationJobStatus.SUCCEEDED
)

fv_latest_values_sql = offline_job.to_sql()

if feature_view.batch_source.field_mapping is not None:
Expand Down