Delete files from Snowflake stage

Hello,

Couldn’t find solution on any of existing topics so created new thread.

I am having an issue with deleting files from a Snowflake stage when running code through a Streamlit application and i’m trying to understand whether this is a limitation of Streamlit in Snowflake, a stored procedure restriction or if i’m missing something.

My setup:

  • Streamlit app running in Snowflake
  • Snowpark used for database interaction
  • calling a Python stored procedure from Streamlit

Inside the stored procedure I attempt to remove a file from a stage using:

session.sql(

“REMOVE @MY_STAGE/text.csv”

).collect()

However execution fails with:

snowflake.snowpark.exceptions.SnowparkSQLException: (1304): 01c47217-0005-3882-0020-29018416e7b3: 090236 (42601): Uncaught exception of type ‘STATEMENT_ERROR’ on line 3 at position 8 : Stored procedure execution error: Unsupported statement type ‘REMOVE_FILES’.

What confuses me is that the SQL command itself works correctly when executed directly in Snowflake, but fails when triggered through Streamlit → Stored Procedure flow. Stored Procedure is executed as CALLER.

I also tried implementing a workaround using a Snowflake Task. The idea was to let Streamlit trigger a process indirectly and have the task handle the file removal operation. Unfortunately, i still wasn’t able to make this approach work as expected.

Questions:

Is REMOVE intentionally unsupported inside Snowflake Python stored procedures?

Is this a limitation specific to Streamlit in Snowflake execution context?

Has anyone found a workaround for deleting files from stages through a Streamlit app?

Is there a recommended architecture or pattern for handling stage file deletion from Streamlit?

Any suggestions or experiences would be appreciated.

Thanks!