-
Notifications
You must be signed in to change notification settings - Fork 142
Open
Labels
bugSomething isn't workingSomething isn't workingneeds triageInitial RCA is requiredInitial RCA is required
Description
-
What version of Python are you using?
3.13 (Running snowpark-python via Snowflake Python stored procedure)
-
What operating system and processor architecture are you using?
Snowflake hosted (see above) within a stored procedure
-
What are the component versions in the environment (
pip freeze)?
snowflake-snowpark-python==1.40.0
pandas==2.3.1
- What did you do?
create or replace temp table system_reference_test(table_name varchar, comment varchar);
WITH test_procedure_system_reference AS PROCEDURE ( table_name string )
RETURNS varchar
LANGUAGE PYTHON
RUNTIME_VERSION = 3.13
PACKAGES = ('snowflake-snowpark-python==1.40.0','pandas==2.3.1')
HANDLER = 'main'
AS
$$
from snowflake.snowpark import Session
def validate_object_name(*args, **kwargs):
return True
def main(session: Session, table_name: str):
try:
df = session.sql("select ?, 'fails to insert'", params=[table_name])
# This fails
df.write.insertInto(table_name)
except:
pass
# This works
session._table_exists = validate_object_name
df = session.sql("select ?, 'success'", params=[table_name])
df.write.insertInto(table_name)
return table_name
$$
call test_procedure_system_reference(SYSTEM$REFERENCE('TABLE', 'system_reference_test', 'CALL', 'INSERT', 'TRUNCATE'));
-- This shows one row, for 'success'
-- The first row fails because _table_exists returns false
-- see https://github.com/snowflakedb/snowpark-python/blob/main/src/snowflake/snowpark/dataframe_writer.py#L1085-L1091
select * from system_reference_test;- What did you expect to see?
I expect to be able to use SYSTEM$REFERENCE with Python stored procedures using Snowpark Python (this works as expected for stored procedures written in Snowflake SQL), i.e. insertInto should write into a referenced table successfully.
- Can you set logging to DEBUG and collect the logs?
I think the snippet above is sufficient to demonstrate the issue, if not let me know and I can provide further input.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingneeds triageInitial RCA is requiredInitial RCA is required