cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

UDF already defined error when using it into a DLT pipeline

6502
New Contributor III

I'm using Unity catalog and defined some UDFs in my catalog.database, as reported by 

show functions in main.default
main.default.getgender
main.default.tointlist
main.default.tostrlist

I can use them from a start warehouse pro:

SELECT main.default.get_gender(10,80,10)

The above statement works.
 
However, from inside a pipeline: 

@dlt.view(
name="vudf"
,comment="Extra data collected from sensor tower APIs required to build the silver table"
)
def test():
   return SQL("""
SELECT ${env.database}.get_gender(10, 80 ,20)
""")

 I got:

pyspark.errors.exceptions.AnalysisException: [ROUTINE_ALREADY_EXISTS] Cannot create the function `main`.`default`.`get_gender` because it already exists.
Choose a different name, drop or replace the existing function, or add the IF NOT EXISTS clause to tolerate a pre-existing function.; line 2 pos 15
1 REPLY 1

Mounika_Tarigop
Databricks Employee
Databricks Employee

Now the Python UDF support is currently in public preview, and it is supported in the current channel as well. Could you please try to re-run the code. 

https://docs.databricks.com/en/delta-live-tables/unity-catalog.html

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group