取得指定名稱的函式。 這個函數可以是暫時函數或函數。 當函數找不到時,會觸發 。AnalysisException
語法
getFunction(functionName: str)
參數
| 參數 | 類型 | 說明 |
|---|---|---|
functionName |
str | 要取得的函數名稱。 |
退貨
Function
函數名稱中可找到的。
Examples
_ = 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: ...