Updated on 2026-11-06 GMT+08:00

Deleting Functions

The section describes how to delete function records from LakeFormation and clear their UDF packages on OBS. The deletion process is as follows:

  1. Retrieve the function metadata (used to locate resource_uris).
  2. Delete the corresponding OBS package (if the function has been partially deleted, the SDK clears the package by prefix to prevent leakage).
  3. Delete the function records from LakeFormation.
  4. If the OBS package fails to be cleared but the function records are successfully deleted from LakeFormation, an exception is thrown to indicate the presence of orphan packages.

Prerequisites

  • The SDK has been installed. For details, see Obtaining and Installing the Catalog SDK.
  • The target database and function name are known. (If the function metadata is unavailable, the SDK clears the OBS package by the {Database}/{Name}/Prefix.)

Function Signature

client.delete_function(*, database=None, name) -> None

Parameter Description

Parameter

Mandatory (Yes/No)

Type

Default Value

Description

database

No

str | None

default_database

Database name. If this parameter is set to None, the default database is used.

name

Yes

str

-

Name of a function.

Return Value

No value is returned (None).

Exception Description

Exception

Trigger Condition

FunctionNotFoundError

The function does not exist. This exception is safely ignored in the deletion process. Then the SDK clears OBS using the prefix.

LakeFormationAPIError

The LakeFormation API fails to be called (due to network issues, authentication failures, or 5xx errors). The exception needs to be reported to notify the caller that the cleanup is not complete.

OBSOperationError

The OBS package fails to be cleared but the function records are successfully deleted from LakeFormation. This indicates the presence of orphan OBS packages.

Sample Code

client.delete_function(name="to_celsius")
print("Function deleted and OBS package cleaned")
  • When the function metadata is unavailable, the SDK clears OBS objects based on the database, function name, and prefix to prevent orphan packages.
  • If the OBS package fails to be deleted but the function records have been deleted from LakeFormation, the SDK throws an OBSOperationError. The caller needs to check for orphan packages based on this error.