hem1891 commented on a change in pull request #25570: [SPARK-23519][SQL] create 
view should work from query with duplicate output columns
URL: https://github.com/apache/spark/pull/25570#discussion_r318280255
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
 ##########
 @@ -360,13 +362,15 @@ object ViewHelper {
   def generateViewProperties(
       properties: Map[String, String],
       session: SparkSession,
-      analyzedPlan: LogicalPlan): Map[String, String] = {
+      analyzedPlan: LogicalPlan,
+      fieldNames: Array[String]): Map[String, String] = {
+    // for createViewCommand queryOutput may be different from fieldNames
     val queryOutput = analyzedPlan.schema.fieldNames
 
     // Generate the query column names, throw an AnalysisException if there 
exists duplicate column
     // names.
     SchemaUtils.checkColumnNameDuplication(
 
 Review comment:
   My bad, I meant `userSpecifiedColumns` is not available in `ViewHelper` not 
`SchemaUtils`
   
   - `CreateViewCommand.prepareTable()` and 
`AlterViewAsCommand.alterPermanentView()` both call  
`ViewHelper.generateViewProperties()`
   - And `ViewHelper.generateViewProperties()` is where we call 
`SchemaUtils.checkColumnNameDuplication()`. The suggestion you provided 
requires `userSpecifiedColumns` to be accessible in 
`ViewHelper.generateViewProperties()`
   - So i added an argument to `ViewHelper.generateViewProperties()` allowing 
`CreateViewCommand` to send aliased schema and `AlterViewAsCommand` to send 
analyzed schema

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


With regards,
Apache Git Services

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

Reply via email to