-
- Downloads
[SPARK-15269][SQL] Removes unexpected empty table directories created while...
[SPARK-15269][SQL] Removes unexpected empty table directories created while creating external Spark SQL data sourcet tables. This PR is an alternative to #13120 authored by xwu0226. ## What changes were proposed in this pull request? When creating an external Spark SQL data source table and persisting its metadata to Hive metastore, we don't use the standard Hive `Table.dataLocation` field because Hive only allows directory paths as data locations while Spark SQL also allows file paths. However, if we don't set `Table.dataLocation`, Hive always creates an unexpected empty table directory under database location, but doesn't remove it while dropping the table (because the table is external). This PR works around this issue by explicitly setting `Table.dataLocation` and then manullay removing the created directory after creating the external table. Please refer to [this JIRA comment][1] for more details about why we chose this approach as a workaround. [1]: https://issues.apache.org/jira/browse/SPARK-15269?focusedCommentId=15297408&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15297408 ## How was this patch tested? 1. A new test case is added in `HiveQuerySuite` for this case 2. Updated `ShowCreateTableSuite` to use the same table name in all test cases. (This is how I hit this issue at the first place.) Author: Cheng Lian <lian@databricks.com> Closes #13270 from liancheng/spark-15269-unpleasant-fix.
Showing
- sql/catalyst/src/main/scala/org/apache/spark/sql/AnalysisException.scala 3 additions, 2 deletions...c/main/scala/org/apache/spark/sql/AnalysisException.scala
- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala 1 addition, 1 deletion...rg/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
- sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala 3 additions, 3 deletions...re/src/main/scala/org/apache/spark/sql/SparkSession.scala
- sql/core/src/main/scala/org/apache/spark/sql/execution/command/createDataSourceTables.scala 2 additions, 2 deletions.../spark/sql/execution/command/createDataSourceTables.scala
- sql/core/src/main/scala/org/apache/spark/sql/internal/HiveSerDe.scala 0 additions, 1 deletion.../main/scala/org/apache/spark/sql/internal/HiveSerDe.scala
- sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala 42 additions, 3 deletions...scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala
- sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSharedState.scala 2 additions, 2 deletions...ain/scala/org/apache/spark/sql/hive/HiveSharedState.scala
- sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala 19 additions, 3 deletions...ala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
- sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogSuite.scala 2 additions, 1 deletion.../org/apache/spark/sql/hive/HiveExternalCatalogSuite.scala
- sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala 13 additions, 0 deletions...org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala
- sql/hive/src/test/scala/org/apache/spark/sql/hive/ShowCreateTableSuite.scala 18 additions, 18 deletions...cala/org/apache/spark/sql/hive/ShowCreateTableSuite.scala
Loading
Please register or sign in to comment