Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/12812#discussion_r61677825
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala
---
@@ -83,6 +93,29 @@ class DDLSuite extends QueryTest with SharedSQLContext
with BeforeAndAfterEach {
catalog.createPartitions(tableName, Seq(part), ignoreIfExists = false)
}
+ test("the qualified path of a database is stored in the catalog") {
+ val catalog = sqlContext.sessionState.catalog
+
+ val path = System.getProperty("java.io.tmpdir")
+ // The generated temp path is not qualified.
+ assert(!path.startsWith("file:/"))
+ sql(s"CREATE DATABASE db1 LOCATION '$path'")
+ val pathInCatalog = new
Path(catalog.getDatabaseMetadata("db1").locationUri).toUri
+ assert("file" === pathInCatalog.getScheme)
+ assert(path === pathInCatalog.getPath)
+
+ withSQLConf(
+ SQLConf.WAREHOUSE_PATH.key ->
(System.getProperty("java.io.tmpdir"))) {
+ sql(s"CREATE DATABASE db2")
+ val pathInCatalog = new
Path(catalog.getDatabaseMetadata("db2").locationUri).toUri
+ assert("file" === pathInCatalog.getScheme)
+ assert(s"${sqlContext.conf.warehousePath}/db2.db" ===
pathInCatalog.getPath)
+ }
+
+ sql("DROP DATABASE db1")
+ sql("DROP DATABASE db2")
+ }
+
test("Create/Drop Database") {
withSQLConf(
SQLConf.WAREHOUSE_PATH.key ->
(System.getProperty("java.io.tmpdir") + File.separator)) {
--- End diff --
We are unable to add `File.separator` directly.
`System.getProperty("java.io.tmpdir")` could have a trailing separator.
Thus, it could break the test cases in some OS. For example, on mac, my local
test cases failed. Below is the error messages I got:
```
CatalogDatabase(db1,,file:/var/folders/4b/sgmfldk15js406vk7lw5llzw0000gn/T/db1.db,Map())
did not equal
CatalogDatabase(db1,,file:/var/folders/4b/sgmfldk15js406vk7lw5llzw0000gn/T//db1.db,Map())
ScalaTestFailureLocation:
org.apache.spark.sql.execution.command.DDLSuite$$anonfun$2$$anonfun$apply$mcV$sp$2$$anonfun$apply$mcV$sp$6
at (DDLSuite.scala:138)
org.scalatest.exceptions.TestFailedException:
CatalogDatabase(db1,,file:/var/folders/4b/sgmfldk15js406vk7lw5llzw0000gn/T/db1.db,Map())
did not equal
CatalogDatabase(db1,,file:/var/folders/4b/sgmfldk15js406vk7lw5llzw0000gn/T//db1.db,Map())
```
Let me know if you want me to fix it.
---
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]