Ngone51 commented on a change in pull request #27651: [SPARK-30903][SQL] Fail 
fast on duplicate columns when analyze columns
URL: https://github.com/apache/spark/pull/27651#discussion_r382445906
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
 ##########
 @@ -3202,8 +3202,16 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
       AnalyzeTableStatement(tableName, partitionSpec, noScan = ctx.identifier 
!= null)
     } else {
       checkPartitionSpec()
-      AnalyzeColumnStatement(
-        tableName, Option(visitIdentifierSeq(ctx.identifierSeq())), allColumns 
= false)
+      val colsOpt = Option(visitIdentifierSeq(ctx.identifierSeq()))
+      colsOpt.foreach { cols =>
+        val duplicates = cols.groupBy(identity).filter(_._2.size > 1).keys
+        if (duplicates.nonEmpty) {
+          throw new ParseException(
 
 Review comment:
   Hmm..the problem is `AnalyzeColumnCommand` of `sql/core` module is 
inaccessible from `CheckAnalysis` of `sql/catalyst` module...

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