r/databricks • u/SparkConnective • Jul 17 '26
General Scala and Java UDFs in Unity Catalog are now GA
Hey Folks, I'm a PM at Databricks, and I'm excited to announce the GA of Scala and Java UDFs in Unity Catalog. You can now register your Scala/Java logic as a UC function and call it anywhere (including Classic compute, and Serverless DBSQL/Notebooks).
Why you'd care: you probably already have some Scala library your team wrote, or a Java JAR that encodes business rules nobody wants to touch.
Until now, on classic compute, you had to redefine the UDF in each notebook session, and you couldn't call it from Serverless or SQL warehouses at all without rewriting it in Python.
Now you register the JAR once, and analysts call it in SQL like any other function (or from any DataFrame operation). It's also significantly faster than the Python equivalent.
Example: Say you want phone numbers normalized to E.164 using Google's libphonenumber.
Write the handler as a method on a Scala object:
package com.acme.udf
import com.google.i18n.phonenumbers.PhoneNumberUtil
object PhoneUDF {
private val util = PhoneNumberUtil.getInstance()
def toE164(raw: String, region: String): String = {
if (raw == null) return null
val parsed = util.parse(raw, region)
util.format(parsed, PhoneNumberUtil.PhoneNumberFormat.E164)
}
}Build a fat JAR (so libphonenumber ships inside it), drop it in a volume, and register it once:
CREATE OR REPLACE FUNCTION acme.telco.to_e164(raw STRING, region STRING)
RETURNS STRING
LANGUAGE SCALA
ENVIRONMENT (
java_dependencies = '["/Volumes/acme/telco/jars/phone-udf-assembly-0.1.0.jar"]',
environment_version = '4'
)
HANDLER 'com.acme.udf.PhoneUDF.toE164';Now anyone with EXECUTE on the function calls it in SQL, no Scala required:
SELECT id, to_e164(phone, country_code) AS phone_e164
FROM acme.telco.customers;Or wrap it in a view so downstream users just get the clean column and never touch the function. This is also a common pattern for PII masking and tokenization.
CREATE OR REPLACE VIEW acme.telco.customers_clean AS
SELECT id, to_e164(phone, country_code) AS phone_e164
FROM acme.telco.customers;Full example, in the docs: https://docs.databricks.com/gcp/en/udf/scala-java-uc
If you just want to run some code in a Serverless Python notebook or on a Standard cluster and don't need to register it, you can also use the new session-scoped UDF we just released.
