cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Using Python UDF in Delta live table

Sabtout
New Contributor II

Hello,

I tried running a python UDF in a Delta Live Table workflow in Advanced mode but it did not run and gave the "Python UDF is not supported in your environment" error.

Can I get a clear picture if the Python External UDFs are supported or not?

2 REPLIES 2

Kaniz
Community Manager
Community Manager

Hi @Sabtout , you can use Python user-defined functions (UDFs) in your SQL queries, but these UDFs must be defined in Python files in the same pipeline before calling them in SQL source files. If you're encountering an error stating "Python UDF is not supported in your environment", it may be due to an environment or configuration issue, or a limitation in the current Delta Live Tables setup.

Sabtout
New Contributor II

Hi @Kaniz 

I ran this SQL query in my Catalog (I'm using Unity Catalog) :

CREATE OR REPLACE FUNCTION cat_projint_dev.silver.GetEditor(prompt STRING)

RETURNS STRING

LANGUAGE PYTHON

AS $$

print(prompt)

$$
 
Then I ran a Delta Live Table workflow using Unity Catalog plugged in my silver catalog like this :

@dlt.table(name="editors_bronze", temporary = True)

def editors_bronze():

    return spark.sql("SELECT prompt,cat_projint_dev.bronze.GetEditor(prompt) AS EDITOR_NAME FROM LIVE.editors_temp_bronze")
 
And then I'm having this issue :
[FEATURE_UNAVAILABLE] Python UDF is not supported in your environment. To use this feature, please contact Databricks Support.
 
Thank you for your help ! ๐Ÿ™‚
Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.