-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-20013][SQL]add a newTablePath parameter for renameTable in ExternalCatalog #17341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,30 +196,6 @@ abstract class ExternalCatalogSuite extends SparkFunSuite with BeforeAndAfterEac | |
| catalog.dropTable("db2", "unknown_table", ignoreIfNotExists = true, purge = false) | ||
| } | ||
|
|
||
| test("rename table") { | ||
| val catalog = newBasicCatalog() | ||
| assert(catalog.listTables("db2").toSet == Set("tbl1", "tbl2")) | ||
| catalog.renameTable("db2", "tbl1", "tblone") | ||
| assert(catalog.listTables("db2").toSet == Set("tblone", "tbl2")) | ||
| } | ||
|
|
||
| test("rename table when database/table does not exist") { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. already existed in SessionCatalogSuite |
||
| val catalog = newBasicCatalog() | ||
| intercept[AnalysisException] { | ||
| catalog.renameTable("unknown_db", "unknown_table", "unknown_table") | ||
| } | ||
| intercept[AnalysisException] { | ||
| catalog.renameTable("db2", "unknown_table", "unknown_table") | ||
| } | ||
| } | ||
|
|
||
| test("rename table when destination table already exists") { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move to |
||
| val catalog = newBasicCatalog() | ||
| intercept[AnalysisException] { | ||
| catalog.renameTable("db2", "tbl1", "tbl2") | ||
| } | ||
| } | ||
|
|
||
| test("alter table") { | ||
| val catalog = newBasicCatalog() | ||
| val tbl1 = catalog.getTable("db2", "tbl1") | ||
|
|
@@ -710,18 +686,6 @@ abstract class ExternalCatalogSuite extends SparkFunSuite with BeforeAndAfterEac | |
| assert(catalog.listFunctions("db2", "func*").toSet == Set("func1", "func2")) | ||
| } | ||
|
|
||
| // -------------------------------------------------------------------------- | ||
| // File System operations | ||
| // -------------------------------------------------------------------------- | ||
|
|
||
| private def exists(uri: URI, children: String*): Boolean = { | ||
| val base = new Path(uri) | ||
| val finalPath = children.foldLeft(base) { | ||
| case (parent, child) => new Path(parent, child) | ||
| } | ||
| base.getFileSystem(new Configuration()).exists(finalPath) | ||
| } | ||
|
|
||
| test("create/drop database should create/delete the directory") { | ||
| val catalog = newBasicCatalog() | ||
| val db = newDb("mydb") | ||
|
|
@@ -732,40 +696,6 @@ abstract class ExternalCatalogSuite extends SparkFunSuite with BeforeAndAfterEac | |
| assert(!exists(db.locationUri)) | ||
| } | ||
|
|
||
| test("create/drop/rename table should create/delete/rename the directory") { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move to |
||
| val catalog = newBasicCatalog() | ||
| val db = catalog.getDatabase("db1") | ||
| val table = CatalogTable( | ||
| identifier = TableIdentifier("my_table", Some("db1")), | ||
| tableType = CatalogTableType.MANAGED, | ||
| storage = CatalogStorageFormat.empty, | ||
| schema = new StructType().add("a", "int").add("b", "string"), | ||
| provider = Some(defaultProvider) | ||
| ) | ||
|
|
||
| catalog.createTable(table, ignoreIfExists = false) | ||
| assert(exists(db.locationUri, "my_table")) | ||
|
|
||
| catalog.renameTable("db1", "my_table", "your_table") | ||
| assert(!exists(db.locationUri, "my_table")) | ||
| assert(exists(db.locationUri, "your_table")) | ||
|
|
||
| catalog.dropTable("db1", "your_table", ignoreIfNotExists = false, purge = false) | ||
| assert(!exists(db.locationUri, "your_table")) | ||
|
|
||
| val externalTable = CatalogTable( | ||
| identifier = TableIdentifier("external_table", Some("db1")), | ||
| tableType = CatalogTableType.EXTERNAL, | ||
| storage = CatalogStorageFormat( | ||
| Some(Utils.createTempDir().toURI), | ||
| None, None, None, false, Map.empty), | ||
| schema = new StructType().add("a", "int").add("b", "string"), | ||
| provider = Some(defaultProvider) | ||
| ) | ||
| catalog.createTable(externalTable, ignoreIfExists = false) | ||
| assert(!exists(db.locationUri, "external_table")) | ||
| } | ||
|
|
||
| test("create/drop/rename partitions should create/delete/rename the directory") { | ||
| val catalog = newBasicCatalog() | ||
| val table = CatalogTable( | ||
|
|
@@ -954,4 +884,14 @@ abstract class CatalogTestUtils { | |
| catalog.listPartitions(db, table).map(_.spec).toSet == parts.map(_.spec).toSet | ||
| } | ||
|
|
||
| // -------------------------------------------------------------------------- | ||
| // File System operations | ||
| // -------------------------------------------------------------------------- | ||
| def exists(uri: URI, children: String*): Boolean = { | ||
| val base = new Path(uri) | ||
| val finalPath = children.foldLeft(base) { | ||
| case (parent, child) => new Path(parent, child) | ||
| } | ||
| base.getFileSystem(new Configuration()).exists(finalPath) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already existed in SessionCatalogSuite