Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/13270#discussion_r64482317
--- 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 --
Added a `__PLACEHOLDER__` suffix to the dummy table location path to fix
case one. And made sure that we handle Hive compatible tables properly.
---
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]