Snowflake UDF returns "Unknown user-defined function" For Existing UDF
Question:
I have a UDF that I can call within my snowflakecomputing.com console.
SELECT DECODE_UTF8('some string')
Works great, until I try to call it programmatically from a Python script. I receive this…
snowflake.connector.errors.ProgrammingError: 002141 (42601):
or:
Unknown user-defined function CS_QA.CS_ANALYTICS.DECODE_UTF8
I am even fully qualifying it (i.e., db.schema.function)
Can anyone suggest a fix? Thank you.
Answers:
Most likely the user(and role assigned) used to connect from Python does not have access to that UDF. This hypothesis could be validated by using INFORMATION_SCHEMA.FUNCTIONS:
The view only displays objects for which the current role for the session has been granted access privileges.
SELECT *
FROM CS_QA.INFORMATION_SCHEMA.FUNCTIONS;
Another possibility is that part of the fully-qualified name is case-sensitive and requires wrapping with "
SELECT "CS_QA"."CS_ANALYTICS".DECODE_UTF8('some string');
I believe, You might have to first switch to database where the function has defined.
USE DATBASE USER_DEF;
SELECT DECODE_UTF8(‘some string’)
That should work.
I have a UDF that I can call within my snowflakecomputing.com console.
SELECT DECODE_UTF8('some string')
Works great, until I try to call it programmatically from a Python script. I receive this…
snowflake.connector.errors.ProgrammingError: 002141 (42601):
or:
Unknown user-defined function CS_QA.CS_ANALYTICS.DECODE_UTF8
I am even fully qualifying it (i.e., db.schema.function)
Can anyone suggest a fix? Thank you.
Most likely the user(and role assigned) used to connect from Python does not have access to that UDF. This hypothesis could be validated by using INFORMATION_SCHEMA.FUNCTIONS:
The view only displays objects for which the current role for the session has been granted access privileges.
SELECT *
FROM CS_QA.INFORMATION_SCHEMA.FUNCTIONS;
Another possibility is that part of the fully-qualified name is case-sensitive and requires wrapping with "
SELECT "CS_QA"."CS_ANALYTICS".DECODE_UTF8('some string');
I believe, You might have to first switch to database where the function has defined.
USE DATBASE USER_DEF;
SELECT DECODE_UTF8(‘some string’)
That should work.