Skip to content

Commit 0ab3942

Browse files
feat: Snowflake skip materialization if no table change (feast-dev#3404)
* feat: Snowflake skip materialization if no table change Signed-off-by: Katy Haynie <74935161+katyhaynie-snowflake@users.noreply.github.com> * removing print statement from offline snowflake.py Signed-off-by: Katy Haynie <74935161+katyhaynie-snowflake@users.noreply.github.com> Signed-off-by: Katy Haynie <74935161+katyhaynie-snowflake@users.noreply.github.com>
1 parent 9d33daf commit 0ab3942

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sdk/python/feast/infra/materialization/snowflake_engine.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pandas as pd
99
from colorama import Fore, Style
1010
from pydantic import Field, StrictStr
11+
from pytz import utc
1112
from tqdm import tqdm
1213

1314
import feast
@@ -256,6 +257,18 @@ def _materialize_one(
256257
end_date=end_date,
257258
)
258259

260+
# Lets check and see if we can skip this query, because the table hasnt changed
261+
# since before the start date of this query
262+
with get_snowflake_conn(self.repo_config.offline_store) as conn:
263+
query = f"""SELECT SYSTEM$LAST_CHANGE_COMMIT_TIME('{feature_view.batch_source.get_table_query_string()}') AS last_commit_change_time"""
264+
last_commit_change_time = (
265+
conn.cursor().execute(query).fetchall()[0][0] / 1_000_000_000
266+
)
267+
if last_commit_change_time < start_date.astimezone(tz=utc).timestamp():
268+
return SnowflakeMaterializationJob(
269+
job_id=job_id, status=MaterializationJobStatus.SUCCEEDED
270+
)
271+
259272
fv_latest_values_sql = offline_job.to_sql()
260273

261274
if feature_view.batch_source.field_mapping is not None:

0 commit comments

Comments
 (0)