DROP FUNCTION

S’applique à :case marquée oui Databricks SQL case marquée oui Databricks Runtime

Supprime une fonction définie par l’utilisateur (UDF) temporaire ou permanente. Pour supprimer une fonction, vous devez en être le propriétaire ou être le propriétaire du schéma, du catalogue ou du metastore où réside la fonction.

Syntaxe

DROP [ TEMPORARY ] FUNCTION [ IF EXISTS ] function_name

Paramètres

  • function_name

    Nom d’une fonction existante. Le nom de la fonction peut facultativement être qualifié avec un nom de schéma.

  • TEMPORARY

    Utilisé pour supprimer une fonction TEMPORARY.

  • IF EXISTS

    S’il est spécifié, aucune exception n’est levée lorsque la fonction n’existe pas.

Exemples

-- Create a permanent function `hello`
> CREATE FUNCTION hello() RETURNS STRING RETURN 'Hello World!';

-- Create a temporary function `hello`
> CREATE TEMPORARY FUNCTION hello() RETURNS STRING RETURN 'Good morning!';

-- List user functions
> SHOW USER FUNCTIONS;
  default.hello
          hello

-- Drop a permanent function
> DROP FUNCTION hello;

-- Try to drop a permanent function which is not present
> DROP FUNCTION hello;
Function 'default.hello' not found in schema 'default'

-- List the functions after dropping, it should list only temporary function
> SHOW USER FUNCTIONS;
 hello

-- Drop a temporary function if exists
> DROP TEMPORARY FUNCTION IF EXISTS hello;