DROP, FUNCTIE

Van toepassing op:controleren met ja Databricks SQL-controle gemarkeerd als ja Databricks Runtime

Hiermee verwijdert u een tijdelijke of permanente door de gebruiker gedefinieerde functie (UDF). Als u een functie wilt verwijderen, moet u de eigenaar zijn of de eigenaar van het schema, de catalogus of de metastore waarin de functie zich bevindt.

Syntaxis

DROP [ TEMPORARY ] FUNCTION [ IF EXISTS ] function_name

Parameters

  • function_name

    De naam van een bestaande functie. De functienaam kan eventueel worden gekwalificeerd met een schemanaam.

  • TIJDELIJKE

    Wordt gebruikt om een TEMPORARY functie te verwijderen.

  • ALS BESTAAT

    Als dit is opgegeven, wordt er geen uitzondering gegenereerd wanneer de functie niet bestaat.

Voorbeelden

-- 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;