Question
How to solve 'SQL compilation error: Object 'SNOWPARK_TEMP_STAGE_FLGVIWVUC' already exists.' issue in snowflake?
I have been using Snowflake to do ML works. I have built a Multiple linear regression. I am writing an output df as a table using session.write_pandas. I get this error
'SQL compilation error: Object 'SNOWPARK_TEMP_STAGE_XXXXX' already exists.'
in snowflake streamlit app. This goes if I refresh the page. But why it occurs? I could not find issues related to this in web.
I get this error only if i write dataframe as pandas. Below is the code where i get this error.
from snowflake.snowpark.context import get_active_session
session = get_active_session()
session.write_pandas(df_final, "TEMPTABLE",database="db",schema="schema", auto_create_table=True, overwrite=True)
I have tried to clear or drop the stage every time before write_pandas code.
import uuid
# Drop the stage if it already exists
session.sql(f"DROP STAGE IF EXISTS {stage_name}").collect()
# Create a new temporary stage
session.sql(f"CREATE TEMPORARY STAGE {stage_name}").collect()
This does not work and what is the real reason I get this error?
Please help I have no idea why this happens.