You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python] create_python_function fails for Decimal and timedelta types in the OSS client #1986
UnitycatalogFunctionClient.create_python_function can't create a function that takes or returns decimal.Decimal or datetime.timedelta. The client derives the type name by splitting the SQL type on < only, so DECIMAL(38, 18) and INTERVAL DAY TO SECOND are sent as the type name and get rejected
To Reproduce
Steps to reproduce the behavior:
Start a local Unity Catalog server
Run:
importdecimalfromunitycatalog.ai.core.clientimportUnitycatalogFunctionClientfromunitycatalog.clientimportApiClient, Configurationapi=ApiClient(Configuration(host="http://localhost:8080/api/2.1/unity-catalog"))
client=UnitycatalogFunctionClient(api_client=api)
defwith_tax(amount: decimal.Decimal) ->str:
"""Adds 10% tax to a price. Args: amount: the price """returnstr(amount*11/10)
client.create_python_function(func=with_tax, catalog="unity", schema="default", replace=True)
It fails with:
pydantic_core._pydantic_core.ValidationError: 1 validation error for FunctionParameterInfo
type_name
Input should be 'BOOLEAN', 'BYTE', 'SHORT', 'INT', 'LONG', 'FLOAT', 'DOUBLE', 'DATE', 'TIMESTAMP', 'TIMESTAMP_NTZ', 'STRING', 'BINARY', 'DECIMAL', 'INTERVAL', 'ARRAY', 'STRUCT', 'MAP', 'CHAR', 'NULL', 'USER_DEFINED_TYPE' or 'TABLE_TYPE' [type=enum, input_value='DECIMAL(38, 18)', input_type=str]
A -> decimal.Decimal return type fails with ValueError: Invalid data_type DECIMAL(38, 18), allowed values are {...}, and datetime.timedelta fails the same two ways with 'INTERVAL DAY TO SECOND'
Expected behavior
The function is created with type name DECIMAL (or INTERVAL) and the full type in the type text, and execute_function works with a Decimal or timedelta argument, the same way list[decimal.Decimal] already does
System [please complete the following information]:
The split happens in ai/core/src/unitycatalog/ai/core/utils/callable_utils.py (extract_function_metadata). The Databricks client builds a SQL CREATE FUNCTION statement instead, so it isn't affected
Activity
maharanay22 commentedon Oct 13, 2026
take
[Python] Fix create_python_function for Decimal and timedelta types i…