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

    https://github.com/apache/spark/pull/13270#discussion_r64500677
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
 ---
    @@ -216,7 +216,25 @@ class SessionCatalog(
         val table = formatTableName(tableDefinition.identifier.table)
         val newTableDefinition = tableDefinition.copy(identifier = 
TableIdentifier(table, Some(db)))
         requireDbExists(db)
    -    externalCatalog.createTable(db, newTableDefinition, ignoreIfExists)
    +
    +    if (newTableDefinition.tableType == CatalogTableType.EXTERNAL) {
    +      // !! HACK ALERT !!
    +      //
    +      // See https://issues.apache.org/jira/browse/SPARK-15269 for more 
details about why we have to
    +      // set `locationUri` and then remove the directory after creating 
the external table:
    +      val tablePath = defaultTablePath(newTableDefinition.identifier)
    +      try {
    +        externalCatalog.createTable(
    +          db,
    +          newTableDefinition.withNewStorage(locationUri = Some(tablePath)),
    +          ignoreIfExists)
    +      } finally {
    +        val path = new Path(tablePath)
    +        FileSystem.get(path.toUri, hadoopConf).delete(path, true)
    +      }
    +    } else {
    +      externalCatalog.createTable(db, newTableDefinition, ignoreIfExists)
    +    }
    --- End diff --
    
    Actually it's `<warehouse-dir>/<table-name>-__PLACEHOLDER__`


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