cloud-fan 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_r317653404
##########
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:
we can make the diff much smaller by changing this line to
```
val colNamesToCheck = if (userSpecifiedColumns.nonEmpty)
userSpecifiedColumns.map(_._1) else queryOutput
SchemaUtils.checkColumnNameDuplication(colNamesToCheck, ...)
```
----------------------------------------------------------------
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]