Skip to content

[Python] OSS create_python_function drops element types from type_json for list and dict parameters #2006

Closed

Description

@maharanay22

Describe the bug

When UnitycatalogFunctionClient.create_python_function registers a function with a list[int] or dict[str, float] parameter, type_text is correct (ARRAY<LONG>, MAP<STRING, DOUBLE>) but type_json only keeps the base type name: {"type": "array"} and {"type": "map"}. create_parameter_info in ai/core/src/unitycatalog/ai/core/utils/callable_utils_oss.py builds it from base_type_name.lower()

The toolkits build their tool schemas from type_json, so the element and value types are lost. The OpenAI tool ends up with "items": {} for the list and "additionalProperties": true for the dict, and the input model accepts any element type

To Reproduce

Against a local Unity Catalog server (main, ddd7720):

import json

from unitycatalog.ai.openai.toolkit import UCFunctionToolkit


def total(xs: list[int], weights: dict[str, float]) -> float:
    """Weighted total.

    Args:
        xs: numbers
        weights: weights
    """
    return float(sum(xs))


client.create_python_function(func=total, catalog="unity", schema="default", replace=True)
for p in client.get_function("unity.default.total").input_params.parameters:
    print(f"{p.name}: type_text={p.type_text} type_json={p.type_json}")
fn = UCFunctionToolkit(function_names=["unity.default.total"], client=client).tools[0]["function"]
print("openai tool properties:", json.dumps(fn["parameters"]["properties"]))
xs: type_text=ARRAY<LONG> type_json={"name": "xs", "type": "array", "nullable": false, "metadata": {"comment": "numbers"}}
weights: type_text=MAP<STRING, DOUBLE> type_json={"name": "weights", "type": "map", "nullable": false, "metadata": {"comment": "weights"}}
openai tool properties: {"xs": {"description": "numbers", "items": {}, "title": "Xs", "type": "array"}, "weights": {"additionalProperties": true, "description": "weights", "title": "Weights", "type": "object"}}

Expected behavior

type_json uses the nested Spark style type JSON that uc_type_json_to_pydantic_type already parses (and that the existing tests in core/tests/core/test_utils.py use), for example {"type": "array", "elementType": "long", "containsNull": true}, so the tool schema says the list holds integers and the map values are numbers

System [please complete the following information]:

  • OS: Windows 11
  • Python 3.10, unitycatalog-ai and unitycatalog-openai from main (ddd7720), local Unity Catalog server built from main

Additional context

The server stores type_json as an opaque string, so this is only on the Python side. I searched open and closed issues and PRs for "type_json", "elementType" and "items" and found only Spark connector work, nothing about the AI library. I have a fix with tests ready

Activity

  1. maharanay22 commented on Oct 17, 2026

    @maharanay22
    ContributorAuthor

    take

  2. added a commit that references this issue on Oct 22, 2026
    4c512b8
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