allisonwang-db opened a new pull request #31791:
URL: https://github.com/apache/spark/pull/31791


   ### What changes were proposed in this pull request?
   This PR extends the current function registry and catalog to support 
table-valued functions by adding a table function registry. It also refactors 
`range` to be a built-in function in the table function registry.
   
   ### Why are the changes needed?
   Currently, Spark resolves table-valued functions very differently from the 
other functions. This change is to make the behavior for table and non-table 
functions consistent. It also allows Spark to display information about 
built-in table-valued functions:
   Before:
   ```scala
   scala> sql("describe function range").show(false)
   +--------------------------+
   |function_desc             |
   +--------------------------+
   |Function: range not found.|
   +--------------------------+
   ```
   After:
   ```scala
   scala> sql("describe function range").show(false)
   
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   |function_desc                                                               
                                                                                
        |
   
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   |Function: range                                                             
                                                                                
        |
   |Class: org.apache.spark.sql.catalyst.plans.logical.Range                    
                                                                                
        |
   |Usage: range(end: long)\nrange(start: long, end: long)\nrange(start: long, 
end: long, step: long)\nrange(start: long, end: long, step: long, 
numPartitions: integer)|
   
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. User will not be able to create a function with name `range` in the 
default database:
   Before:
   ```scala
   scala> sql("create function range as 'range'")
   res3: org.apache.spark.sql.DataFrame = []
   ```
   After:
   ```
   scala> sql("create function range as 'range'")
   org.apache.spark.sql.catalyst.analysis.FunctionAlreadyExistsException: 
Function 'default.range' already exists in database 'default'
   ```
   
   ### How was this patch tested?
   Unit test
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to