getFunction
Obtenez la fonction avec le nom spécifié. Cette fonction peut être une fonction temporaire ou une fonction. Cela renvoie une AnalysisException lorsque la fonction est introuvable.
Syntaxe
getFunction(functionName: str)
parameter
parameter | Type | Description |
|---|---|---|
| str | Nom de la fonction à obtenir. |
Renvoie
Function
La fonction trouvée par le nom.
Exemples
Python
_ = 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: ...