HyukjinKwon opened a new pull request #28633:
URL: https://github.com/apache/spark/pull/28633


   ### What changes were proposed in this pull request?
   
   This PR proposes to set the alias, and class name in its `ExpressionInfo` 
for `struct`.
   - Class name in `ExpressionInfo`
     - from: `org.apache.spark.sql.catalyst.expressions.NamedStruct`
     - to:`org.apache.spark.sql.catalyst.expressions.CreateNamedStruct`
   - Alias name: `named_struct(col1, v, ...)` -> `struct(v, ...)`
   
   ### Why are the changes needed?
   
   To show the correct output name and class names to users.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes.
   
   **Before:**
   
   ```scala
   scala> sql("DESC FUNCTION struct").show(false)
   
+------------------------------------------------------------------------------------+
   |function_desc                                                               
        |
   
+------------------------------------------------------------------------------------+
   |Function: struct                                                            
        |
   |Class: org.apache.spark.sql.catalyst.expressions.NamedStruct                
        |
   |Usage: struct(col1, col2, col3, ...) - Creates a struct with the given 
field values.|
   
+------------------------------------------------------------------------------------+
   ```
   
   ```scala
   scala> sql("SELECT struct(1, 2)").show(false)
   +------------------------------+
   |named_struct(col1, 1, col2, 2)|
   +------------------------------+
   |[1, 2]                        |
   +------------------------------+
   ```
   
   
   **After:**
   
   ```scala
   scala> sql("DESC FUNCTION struct").show(false)
   
+------------------------------------------------------------------------------------+
   |function_desc                                                               
        |
   
+------------------------------------------------------------------------------------+
   |Function: struct                                                            
        |
   |Class: org.apache.spark.sql.catalyst.expressions.CreateNamedStruct          
        |
   |Usage: struct(col1, col2, col3, ...) - Creates a struct with the given 
field values.|
   
+------------------------------------------------------------------------------------+
   ```
   
   ```scala
   scala> sql("SELECT struct(1, 2)").show(false)
   +------------+
   |struct(1, 2)|
   +------------+
   |[1, 2]      |
   +------------+
   ```
   
   ### How was this patch tested?
   
   Manually tested, and Jenkins tests.
   


----------------------------------------------------------------
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