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

    https://github.com/apache/spark/pull/15805#discussion_r86932312
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala ---
    @@ -324,38 +324,45 @@ case class TruncateTableCommand(
       override def run(spark: SparkSession): Seq[Row] = {
         val catalog = spark.sessionState.catalog
         val table = catalog.getTableMetadata(tableName)
    -    val tableIdentwithDB = table.identifier.quotedString
    +    val tableIdentWithDB = table.identifier.quotedString
     
         if (table.tableType == CatalogTableType.EXTERNAL) {
           throw new AnalysisException(
    -        s"Operation not allowed: TRUNCATE TABLE on external tables: 
$tableIdentwithDB")
    +        s"Operation not allowed: TRUNCATE TABLE on external tables: 
$tableIdentWithDB")
         }
         if (table.tableType == CatalogTableType.VIEW) {
           throw new AnalysisException(
    -        s"Operation not allowed: TRUNCATE TABLE on views: 
$tableIdentwithDB")
    +        s"Operation not allowed: TRUNCATE TABLE on views: 
$tableIdentWithDB")
         }
         if (table.partitionColumnNames.isEmpty && partitionSpec.isDefined) {
           throw new AnalysisException(
             s"Operation not allowed: TRUNCATE TABLE ... PARTITION is not 
supported " +
    -        s"for tables that are not partitioned: $tableIdentwithDB")
    +        s"for tables that are not partitioned: $tableIdentWithDB")
         }
         if (partitionSpec.isDefined) {
           DDLUtils.verifyPartitionProviderIsHive(spark, table, "TRUNCATE TABLE 
... PARTITION")
         }
    +
    +    val partCols = table.partitionColumnNames
         val locations =
    -      if (table.partitionColumnNames.isEmpty) {
    +      if (partCols.isEmpty) {
             Seq(table.storage.locationUri)
           } else {
    -        // Here we diverge from Hive when the given partition spec 
contains all partition columns
    -        // but no partition is matched: Hive will throw an exception and 
we just do nothing.
             val normalizedSpec = partitionSpec.map { spec =>
               PartitioningUtils.normalizePartitionSpec(
                 spec,
    -            table.partitionColumnNames,
    +            partCols,
                 table.identifier.quotedString,
                 spark.sessionState.conf.resolver)
             }
    -        catalog.listPartitions(table.identifier, 
normalizedSpec).map(_.storage.locationUri)
    +        val parts =
    --- End diff --
    
    Nit: How about `partLocations`?


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