cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Creating java UDF for Spark SQL

sm1274
New Contributor

Hello, 

I have created a sample java UDF which masks few characters of a string. However I facing couple of issues when uploading and using it.

First I could only import it, which for now is OK. But when do the following,

create function udf_mask as 'baffleCrypto' using jar '/Workspace/Users/sumandra@baffle.io/baffle-databricks-udf-1.0-SNAPSHOT.jar' 
Throws an error 
[NOT_SUPPORTED_WITH_DB_SQL] CREATE FUNCTION is not supported on a SQL warehouse.
 
Is there an example on how to load a jar and then use it as external function. I followed the this guide 
https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-ddl-create-function.html
Even cut-n-paste errors out. 
 
Any ideas?
1 REPLY 1

Kaniz
Community Manager
Community Manager

Hi @sm1274The error message you received indicates that the CREATE FUNCTION statement is not supported on a Databricks SQL endpoint. This statement is the specific error message you're seeing indicating that you're trying to run the CREATE FUNCTION statement in the context of a SQL warehouse, which is not supported by Databricks.

It seems like you're trying to create a user-defined function (UDF) in Databricks using a JAR file. However, creating UDFs with JARs isn't supported in a Databricks SQL endpoint.

To create UDFs with JAR files, you need to use Databricks Runtime for ML (MLflow).

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!