Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17287#discussion_r106568913
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala
 ---
    @@ -27,41 +27,67 @@ import 
org.apache.spark.sql.catalyst.parser.CatalystSqlParser
     import org.apache.spark.sql.catalyst.plans.PlanTest
     import org.apache.spark.sql.catalyst.plans.logical.{Range, SubqueryAlias, 
View}
     
    +class InMemorySessionCatalogSuite extends SessionCatalogSuite {
    +  protected val utils = new CatalogTestUtils {
    +    override val tableInputFormat: String = 
"com.fruit.eyephone.CameraInputFormat"
    +    override val tableOutputFormat: String = 
"com.fruit.eyephone.CameraOutputFormat"
    +    override val defaultProvider: String = "parquet"
    +    override def newEmptyCatalog(): ExternalCatalog = new InMemoryCatalog
    +  }
    +}
    +
     /**
    - * Tests for [[SessionCatalog]] that assume that [[InMemoryCatalog]] is 
correctly implemented.
    + * Tests for [[SessionCatalog]]
      *
      * Note: many of the methods here are very similar to the ones in 
[[ExternalCatalogSuite]].
      * This is because [[SessionCatalog]] and [[ExternalCatalog]] share many 
similar method
      * signatures but do not extend a common parent. This is largely by design 
but
      * unfortunately leads to very similar test code in two places.
      */
    -class SessionCatalogSuite extends PlanTest {
    -  private val utils = new CatalogTestUtils {
    -    override val tableInputFormat: String = 
"com.fruit.eyephone.CameraInputFormat"
    -    override val tableOutputFormat: String = 
"com.fruit.eyephone.CameraOutputFormat"
    -    override val defaultProvider: String = "parquet"
    -    override def newEmptyCatalog(): ExternalCatalog = new InMemoryCatalog
    -  }
    +abstract class SessionCatalogSuite extends PlanTest {
    +  protected val utils: CatalogTestUtils
    +
    +  protected val isHiveExternalCatalog = false
     
       import utils._
     
    +  private def withBasicCatalog(f: SessionCatalog => Unit): Unit = {
    +    val catalog = new SessionCatalog(newBasicCatalog())
    +    catalog.createDatabase(newDb("default"), ignoreIfExists = true)
    +    try {
    +      f(catalog)
    +    } finally {
    +      catalog.reset()
    +    }
    +  }
    +
    +  private def withEmptyCatalog(f: SessionCatalog => Unit): Unit = {
    +    val catalog = new SessionCatalog(newEmptyCatalog())
    +    catalog.createDatabase(newDb("default"), ignoreIfExists = true)
    +    try {
    +      f(catalog)
    +    } finally {
    +      catalog.reset()
    +    }
    +  }
       // 
--------------------------------------------------------------------------
       // Databases
       // 
--------------------------------------------------------------------------
     
       test("basic create and list databases") {
    -    val catalog = new SessionCatalog(newEmptyCatalog())
    -    catalog.createDatabase(newDb("default"), ignoreIfExists = true)
    -    assert(catalog.databaseExists("default"))
    -    assert(!catalog.databaseExists("testing"))
    -    assert(!catalog.databaseExists("testing2"))
    -    catalog.createDatabase(newDb("testing"), ignoreIfExists = false)
    -    assert(catalog.databaseExists("testing"))
    -    assert(catalog.listDatabases().toSet == Set("default", "testing"))
    -    catalog.createDatabase(newDb("testing2"), ignoreIfExists = false)
    -    assert(catalog.listDatabases().toSet == Set("default", "testing", 
"testing2"))
    -    assert(catalog.databaseExists("testing2"))
    -    assert(!catalog.databaseExists("does_not_exist"))
    +    withEmptyCatalog { catalog =>
    +      catalog.createDatabase(newDb("default"), ignoreIfExists = true)
    --- End diff --
    
    this is an example that we should not create default database in 
`withEmptyCatalog`, 


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

Reply via email to