def validate_input_parameter(
    parameter: Union[FunctionParameterInfo, Dict[str, str]],
) -> FunctionParameterInfo:
    """
    Validate the input parameter and convert it to FunctionParameterInfo.

    Args:
        parameter: The input parameter to validate. If it is a dict, it will be converted to FunctionParameterInfo.

    Returns:
        The validated FunctionParameterInfo.
    """

    if isinstance(parameter, dict):
        parameter = FunctionParameterInfo(**parameter)
    elif not isinstance(parameter, FunctionParameterInfo):
        raise TypeError(
            f"Input parameter should be either a dict or an instance of "
            f"FunctionParameterInfo, but got {type(parameter)}"
        )

    required_fields = ["name", "type_name", "type_text", "type_json"]

    if missing_fields := [
        field for field in required_fields if getattr(parameter, field, None) is None
    ]:
        raise ValueError(
            f"Missing required fields in input parameter '{parameter}': {missing_fields}."
        )

    if isinstance(type_name := parameter.type_name, Enum):
        type_name = type_name.value
    elif not isinstance(type_name, str):
        raise ValueError(
            f"Invalid type_name '{type_name}' in input parameter '{parameter.name}'. Must be a string or Enum instance."
        )

    complex_type_names = ["ARRAY", "MAP", "STRUCT", "DECIMAL", "INTERVAL"]
    for complex_type_name in complex_type_names:
        if type_name.startswith(complex_type_name):
            parameter.type_name = complex_type_name
            return parameter

    if type_name not in ALLOWED_DATA_TYPES:
        raise ValueError(
            f"Invalid type_name {type_name} in input parameter "
            f"{parameter}, allowed values are {ALLOWED_DATA_TYPES}."
        )
    return parameter

    Validate the input parameter and convert it to FunctionParameterInfo.

    Args:
        parameter: The input parameter to validate. If it is a dict, it will be converted to FunctionParameterInfo.

    Returns:
        The validated FunctionParameterInfo.
    
ai/core/src/unitycatalog/ai/core/client.py