Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18079#discussion_r118833872
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -592,7 +592,23 @@ class Analyzer(
         def resolveRelation(plan: LogicalPlan): LogicalPlan = plan match {
           case u: UnresolvedRelation if 
!isRunningDirectlyOnFiles(u.tableIdentifier) =>
             val defaultDatabase = AnalysisContext.get.defaultDatabase
    -        val relation = lookupTableFromCatalog(u, defaultDatabase)
    +        val foundRelation = lookupTableFromCatalog(u, defaultDatabase)
    +
    +        // If alias names assigned, add `Project` with the aliases
    +        val relation = if (u.outputNames.nonEmpty) {
    +          val outputAttrs = foundRelation.output
    +          // Checks if the number of the aliases is equal to expected one
    +          if (u.outputNames.size != outputAttrs.size) {
    +            u.failAnalysis(s"expected ${outputAttrs.size} columns but 
found " +
    +              s"${u.outputNames.size} columns in alias names")
    --- End diff --
    
    >The number of column aliases does not match the number of column of the 
table `$tableName`. Number of column aliases: ${u.outputNames.size}; Number of 
columns: ${outputAttrs.size}.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to