File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
main/scala/org/apache/spark/sql/execution/command
test/scala/org/apache/spark/sql/execution/command Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ case class RefreshFunctionCommand(
251251
252252 override def run (sparkSession : SparkSession ): Seq [Row ] = {
253253 val catalog = sparkSession.sessionState.catalog
254- if (FunctionRegistry .builtin.functionExists(FunctionIdentifier (functionName))) {
254+ if (FunctionRegistry .builtin.functionExists(FunctionIdentifier (functionName, databaseName ))) {
255255 throw new AnalysisException (s " Cannot refresh built-in function $functionName" )
256256 }
257257 if (catalog.isTemporaryFunction(FunctionIdentifier (functionName, databaseName))) {
Original file line number Diff line number Diff line change @@ -3036,6 +3036,9 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
30363036 sql(" REFRESH FUNCTION md5" )
30373037 }.getMessage
30383038 assert(msg.contains(" Cannot refresh built-in function" ))
3039+ intercept[NoSuchFunctionException ] {
3040+ sql(" REFRESH FUNCTION default.md5" )
3041+ }
30393042
30403043 withUserDefinedFunction(" func1" -> true ) {
30413044 sql(" CREATE TEMPORARY FUNCTION func1 AS 'test.org.apache.spark.sql.MyDoubleAvg'" )
@@ -3079,6 +3082,21 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
30793082 assert(! spark.sessionState.catalog.isRegisteredFunction(func))
30803083 }
30813084 }
3085+
3086+ test(" REFRESH FUNCTION persistent function with the same name as the built-in function" ) {
3087+ withUserDefinedFunction(" rand" -> false ) {
3088+ val rand = FunctionIdentifier (" rand" , Some (" default" ))
3089+ sql(" CREATE FUNCTION rand AS 'test.org.apache.spark.sql.MyDoubleAvg'" )
3090+ assert(! spark.sessionState.catalog.isRegisteredFunction(rand))
3091+ val msg = intercept[AnalysisException ] {
3092+ sql(" REFRESH FUNCTION rand" )
3093+ }.getMessage
3094+ assert(msg.contains(" Cannot refresh built-in function" ))
3095+ assert(! spark.sessionState.catalog.isRegisteredFunction(rand))
3096+ sql(" REFRESH FUNCTION default.rand" )
3097+ assert(spark.sessionState.catalog.isRegisteredFunction(rand))
3098+ }
3099+ }
30823100}
30833101
30843102object FakeLocalFsFileSystem {
You can’t perform that action at this time.
0 commit comments