spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liancheng <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-15334][SQL] HiveClient facade not compa...
Date Mon, 16 May 2016 13:34:48 GMT
Github user liancheng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13127#discussion_r63352618
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/client/VersionsSuite.scala
---
    @@ -130,109 +124,343 @@ class VersionsSuite extends SparkFunSuite with Logging {
         test(s"$version: create client") {
           client = null
           System.gc() // Hack to avoid SEGV on some JVM versions.
    +      val hadoopConf = new Configuration();
    +      hadoopConf.set("test", "success")
           client =
             IsolatedClientLoader.forVersion(
               hiveMetastoreVersion = version,
               hadoopVersion = VersionInfo.getVersion,
               sparkConf = sparkConf,
    -          hadoopConf = new Configuration(),
    +          hadoopConf,
               config = buildConf(),
               ivyPath = ivyPath).createClient()
         }
     
    +    def table(database: String, tableName: String): CatalogTable = {
    +      CatalogTable(
    +        identifier = TableIdentifier(tableName, Some(database)),
    +        tableType = CatalogTableType.MANAGED,
    +        schema = Seq(CatalogColumn("key", "int")),
    +        storage = CatalogStorageFormat(
    +          locationUri = None,
    +          inputFormat = Some(classOf[org.apache.hadoop.mapred.TextInputFormat].getName),
    +          outputFormat = Some(
    +            classOf[org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat[_, _]].getName),
    +          serde = Some(classOf[org.apache.hadoop.hive.serde2.`lazy`.LazySimpleSerDe].getName()),
    +          compressed = false,
    +          serdeProperties = Map.empty
    +        ))
    +    }
    +
    +    ///////////////////////////////////////////////////////////////////////////
    +    // Database related API
    +    ///////////////////////////////////////////////////////////////////////////
    +
    +    val tempDatabasePath = Utils.createTempDir().getCanonicalPath
    +
         test(s"$version: createDatabase") {
    -      val db = CatalogDatabase("default", "desc", "loc", Map())
    -      client.createDatabase(db, ignoreIfExists = true)
    +      val defaultDB = CatalogDatabase("default", "desc", "loc", Map())
    +      client.createDatabase(defaultDB, ignoreIfExists = true)
    +      val tempDB = CatalogDatabase(
    +        "temporary", description = "test create", tempDatabasePath, Map())
    +      client.createDatabase(tempDB, ignoreIfExists = true)
    +    }
    +
    +    test(s"$version: setCurrentDatabase") {
    +      client.setCurrentDatabase("default")
    +    }
    +
    +    test(s"$version: getDatabase") {
    +      // No exception should be thrown
    +      client.getDatabase("default")
    +    }
    +
    +    test(s"$version: getDatabaseOption") {
    +      assert(client.getDatabaseOption("default").isDefined)
    +      assert(client.getDatabaseOption("nonexist") == None)
         }
     
    +    test(s"$version: listDatabases") {
    +      assert(client.listDatabases("defau.*") == Seq("default"))
    +    }
    +
    +    test(s"$version: alterDatabase") {
    +      val database = client.getDatabase("temporary").copy(properties = Map("flag" ->
"true"))
    +      client.alterDatabase(database)
    +      assert(client.getDatabase("temporary").properties.contains("flag"))
    +    }
    +
    +    test(s"$version: dropDatabase") {
    +      assert(client.getDatabaseOption("temporary").isDefined)
    +      client.dropDatabase("temporary", ignoreIfNotExists = false, cascade = true)
    +      assert(client.getDatabaseOption("temporary").isEmpty)
    +    }
    +
    +    ///////////////////////////////////////////////////////////////////////////
    +    // Table related API
    +    ///////////////////////////////////////////////////////////////////////////
    +
         test(s"$version: createTable") {
    -      val table =
    -        CatalogTable(
    -          identifier = TableIdentifier("src", Some("default")),
    -          tableType = CatalogTableType.MANAGED,
    -          schema = Seq(CatalogColumn("key", "int")),
    -          storage = CatalogStorageFormat(
    -            locationUri = None,
    -            inputFormat = Some(classOf[org.apache.hadoop.mapred.TextInputFormat].getName),
    -            outputFormat = Some(
    -              classOf[org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat[_, _]].getName),
    -            serde = Some(classOf[org.apache.hadoop.hive.serde2.`lazy`.LazySimpleSerDe].getName()),
    -            compressed = false,
    -            serdeProperties = Map.empty
    -          ))
    -
    -      client.createTable(table, ignoreIfExists = false)
    +      client.createTable(table("default", tableName = "src"), ignoreIfExists = false)
    +      // Creates a temporary table
    +      client.createTable(table("default", "temporary"), ignoreIfExists = false)
    +    }
    +
    +    test(s"$version: loadTable") {
    +      client.loadTable(
    +        emptyDir,
    +        tableName = "src",
    +        replace = false,
    +        holdDDLTime = false)
         }
     
         test(s"$version: getTable") {
    +      // No exception should be thrown
           client.getTable("default", "src")
         }
     
    -    test(s"$version: listTables") {
    -      assert(client.listTables("default") === Seq("src"))
    +    test(s"$version: getTableOption") {
    +      assert(client.getTableOption("default", "src").isDefined)
         }
     
    -    test(s"$version: getDatabase") {
    -      client.getDatabase("default")
    +    test(s"$version: alterTable(table: CatalogTable)") {
    +      val newTable = client.getTable("default", "src").copy(properties = Map("changed"
-> ""))
    +      client.alterTable(newTable)
    +      assert(client.getTable("default", "src").properties.contains("changed"))
         }
     
    -    test(s"$version: alterTable") {
    -      client.alterTable(client.getTable("default", "src"))
    +    test(s"$version: alterTable(tableName: String, table: CatalogTable)") {
    +      val newTable = client.getTable("default", "src").copy(properties = Map("changedAgain"
-> ""))
    +      client.alterTable("src", newTable)
    +      assert(client.getTable("default", "src").properties.contains("changedAgain"))
         }
     
    -    test(s"$version: set command") {
    -      client.runSqlHive("SET spark.sql.test.key=1")
    +    test(s"$version: listTables(database)") {
    +      assert(client.listTables("default") === Seq("src", "temporary"))
    +    }
    +
    +    test(s"$version: listTables(database, pattern)") {
    +      assert(client.listTables("default", pattern = "src") === Seq("src"))
    +      assert(client.listTables("default", pattern = "nonexist") === Seq.empty[String])
    --- End diff --
    
    Nit: `.isEmpty` is enough for this assert.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message