Skip to content

Commit

Permalink
fix: Check for snowflake functions when setting up materialization en…
Browse files Browse the repository at this point in the history
…gine (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>
  • Loading branch information
benchoncy authored Aug 30, 2024
1 parent a68cf37 commit c365b4e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sdk/python/feast/infra/materialization/snowflake_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,16 @@ def update(
stage_context = f'"{self.repo_config.batch_engine.database}"."{self.repo_config.batch_engine.schema_}"'
stage_path = f'{stage_context}."feast_{project}"'
with GetSnowflakeConnection(self.repo_config.batch_engine) as conn:
query = f"SHOW STAGES IN {stage_context}"
query = f"SHOW USER FUNCTIONS LIKE 'FEAST_{project.upper()}%' IN SCHEMA {stage_context}"
cursor = execute_snowflake_statement(conn, query)
stage_list = pd.DataFrame(
function_list = pd.DataFrame(
cursor.fetchall(),
columns=[column.name for column in cursor.description],
)

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

query = f"CREATE STAGE {stage_path}"
query = f"CREATE STAGE IF NOT EXISTS {stage_path}"
execute_snowflake_statement(conn, query)

copy_path, zip_path = package_snowpark_zip(project)
Expand Down

0 comments on commit c365b4e

Please sign in to comment.