Skip to content

Commit c365b4e

Browse files
authored
fix: Check for snowflake functions when setting up materialization engine (feast-dev#4456)
* Check for snowflake functions over stage Signed-off-by: Ben Stuart <ben@benstuart.ie> * Refactor stage_list to function_list Signed-off-by: Ben Stuart <ben@benstuart.ie> --------- Signed-off-by: Ben Stuart <ben@benstuart.ie>
1 parent a68cf37 commit c365b4e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ def update(
128128
stage_context = f'"{self.repo_config.batch_engine.database}"."{self.repo_config.batch_engine.schema_}"'
129129
stage_path = f'{stage_context}."feast_{project}"'
130130
with GetSnowflakeConnection(self.repo_config.batch_engine) as conn:
131-
query = f"SHOW STAGES IN {stage_context}"
131+
query = f"SHOW USER FUNCTIONS LIKE 'FEAST_{project.upper()}%' IN SCHEMA {stage_context}"
132132
cursor = execute_snowflake_statement(conn, query)
133-
stage_list = pd.DataFrame(
133+
function_list = pd.DataFrame(
134134
cursor.fetchall(),
135135
columns=[column.name for column in cursor.description],
136136
)
137137

138-
# if the stage already exists,
138+
# if the SHOW FUNCTIONS query returns results,
139139
# assumes that the materialization functions have been deployed
140-
if f"feast_{project}" in stage_list["name"].tolist():
140+
if len(function_list.index) > 0:
141141
click.echo(
142142
f"Materialization functions for {Style.BRIGHT + Fore.GREEN}{project}{Style.RESET_ALL} already detected."
143143
)
@@ -149,7 +149,7 @@ def update(
149149
)
150150
click.echo()
151151

152-
query = f"CREATE STAGE {stage_path}"
152+
query = f"CREATE STAGE IF NOT EXISTS {stage_path}"
153153
execute_snowflake_statement(conn, query)
154154

155155
copy_path, zip_path = package_snowpark_zip(project)

0 commit comments

Comments
 (0)