pyspark.sql.Catalog.getFunction

Catalog.getFunction(functionName: str) → pyspark.sql.catalog.Function

Get the function with the specified name. This function can be a temporary function or a function. This throws an AnalysisException when the function cannot be found.

Parameters
tableNamestr

name of the function to check existence.

Examples

>>> func = spark.sql("CREATE FUNCTION my_func1 AS 'test.org.apache.spark.sql.MyDoubleAvg'")
>>> spark.catalog.getFunction("my_func1")
Function(name='my_func1', catalog=None, namespace=['default'], ...
>>> spark.catalog.getFunction("default.my_func1")
Function(name='my_func1', catalog=None, namespace=['default'], ...
>>> spark.catalog.getFunction("spark_catalog.default.my_func1")
Function(name='my_func1', catalog='spark_catalog', namespace=['default'], ...
>>> spark.catalog.getFunction("my_func2")
Traceback (most recent call last):
    ...
pyspark.sql.utils.AnalysisException: ...