Skip to content

[Python] create_python_function fails for Decimal and timedelta types in the OSS client #1986

Closed

Description

@maharanay22

Describe the bug

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:

  1. Start a local Unity Catalog server
  2. Run:
import decimal
from unitycatalog.ai.core.client import UnitycatalogFunctionClient
from unitycatalog.client import ApiClient, Configuration

api = ApiClient(Configuration(host="http://localhost:8080/api/2.1/unity-catalog"))
client = UnitycatalogFunctionClient(api_client=api)

def with_tax(amount: decimal.Decimal) -> str:
    """Adds 10% tax to a price.

    Args:
        amount: the price
    """
    return str(amount * 11 / 10)

client.create_python_function(func=with_tax, catalog="unity", schema="default", replace=True)
  1. 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]:

  • OS: Windows 11 (the bug isn't OS specific)
  • unitycatalog-ai: main at 45c6397

Additional context

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

  1. maharanay22 commented on Oct 13, 2026

    @maharanay22
    ContributorAuthor

    take

  2. added a commit that references this issue on Oct 20, 2026
    484acea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions