- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2025 06:08 AM
Hi @GiriSreerangam, You cannot use a Unity Catalog user-defined function (UDF) in Databricks to perform Spark read from a CSV and write to a table. Unity Catalog Python UDFs execute in a secure, isolated environment without access to the file system or the Spark context, and hence results in errors because spark home is not found.
They are intended for value transformations and can only return a single value (scalar), not perform data read/write operations or return DataFrames.
A recommended approach is to register your Spark read/write logic notebook as a Databricks Job, which can then be triggered either from the Databricks UI or programmatically via the Jobs API. If you wish to integrate this with an AI tool, you can encapsulate the Jobs API as a “function tool” to automate these workflows when needed.