getFunction

Obtenga la función con el nombre especificado. Esta función puede ser una función temporal o una función. Esto produce una AnalysisException excepción cuando no se encuentra la función.

Sintaxis

getFunction(functionName: str)

Parámetros

Parámetro Tipo Descripción
functionName str Nombre de la función que se va a obtener.

Devoluciones

Function

Función encontrada por el nombre.

Ejemplos

_ = spark.sql(
    "CREATE FUNCTION my_func1 AS 'test.org.apache.spark.sql.MyDoubleAvg'")
spark.catalog.getFunction("my_func1")
# Function(name='my_func1', catalog='spark_catalog', namespace=['default'], ...

# Using the fully qualified name for function name.
spark.catalog.getFunction("default.my_func1")
# Function(name='my_func1', catalog='spark_catalog', namespace=['default'], ...
spark.catalog.getFunction("spark_catalog.default.my_func1")
# Function(name='my_func1', catalog='spark_catalog', namespace=['default'], ...

# Throw an analysis exception when the function does not exist.
spark.catalog.getFunction("my_func2")
# Traceback (most recent call last):
#     ...
# AnalysisException: ...