DROP-FUNKTION

Gäller för:check markerad ja Databricks SQL-kontroll markerad ja Databricks Runtime

Tar bort en tillfällig eller permanent användardefinierad funktion (UDF). Om du vill ta bort en funktion måste du vara dess ägare, eller ägaren av schemat, katalogen eller metaarkivet som funktionen finns i.

Syntax

DROP [ TEMPORARY ] FUNCTION [ IF EXISTS ] function_name

Parametrar

  • function_name

    Namnet på en befintlig funktion. Funktionsnamnet kan eventuellt kvalificeras med ett schemanamn.

  • TILLFÄLLIGA

    Används för att ta bort en TEMPORARY funktion.

  • OM FINNS

    Om det anges utlöses inget undantag när funktionen inte finns.

Exempel

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