関数を取得する
指定された名前の関数を取得します。この関数は一時的な関数でも、関数でも構いません。関数が見つからない場合は、 AnalysisExceptionがスローされます。
構文
getFunction(functionName: str)
パラメーター
パラメーター | Type | 説明 |
|---|---|---|
| str | 取得する関数の名前。 |
戻り値
Function
名前で見つかった関数。
例
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: ...