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

    https://github.com/apache/spark/pull/14482#discussion_r73408103
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
 ---
    @@ -61,6 +64,38 @@ trait CheckAnalysis extends PredicateHelper {
         }
       }
     
    +  private def checkColumnNames(tableDesc: CatalogTable): Unit = {
    +    val colNames = tableDesc.schema.map(_.name)
    +    val colNamesSet = colNames.toSet
    +    checkDuplicatedColumnNames(colNames, colNamesSet, "table definition of 
" + tableDesc.identifier)
    +
    +    def requireSubsetOfSchema(subColNames: Seq[String], colType: String): 
Unit = {
    +      val subColNamesSet = subColNames.toSet
    +      checkDuplicatedColumnNames(subColNames, subColNamesSet, colType)
    +      if (!subColNamesSet.subsetOf(colNamesSet)) {
    +        failAnalysis(s"$colType columns (${subColNames.mkString(", ")}) 
must be a subset of " +
    +          s"schema (${colNames.mkString(", ")}) in table 
'${tableDesc.identifier}'")
    +      }
    +    }
    +
    +    // Verify that the provided columns are part of the schema
    +    requireSubsetOfSchema(tableDesc.partitionColumnNames, "partition")
    +    
requireSubsetOfSchema(tableDesc.bucketSpec.map(_.bucketColumnNames).getOrElse(Nil),
 "bucket")
    +    
requireSubsetOfSchema(tableDesc.bucketSpec.map(_.sortColumnNames).getOrElse(Nil),
 "sort")
    +  }
    +
    +  private def checkDuplicatedColumnNames(
    +      colNames: Seq[String],
    +      colNamesSet: Set[String],
    +      colType: String): Unit = {
    +    if (colNamesSet.size != colNames.length) {
    +      val duplicateColumns = colNames.groupBy(identity).collect {
    +        case (x, ys) if ys.length > 1 => quoteIdentifier(x)
    +      }
    --- End diff --
    
    Do we need to consider the case sensitivity here?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to