Github user yhuai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16296#discussion_r94700062
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveDDLCommandSuite.scala ---
    @@ -592,4 +597,77 @@ class HiveDDLCommandSuite extends PlanTest with 
SQLTestUtils with TestHiveSingle
         val hiveClient = 
spark.sharedState.externalCatalog.asInstanceOf[HiveExternalCatalog].client
         assert(hiveClient.getConf("hive.in.test", "") == "true")
       }
    +
    +  test("create hive serde table with new syntax - basic") {
    +    val sql =
    +      """
    +        |CREATE TABLE t
    +        |(id int, name string COMMENT 'blabla')
    +        |USING hive
    +        |OPTIONS (format 'parquet', my_prop 1)
    +        |LOCATION '/tmp/file'
    +        |COMMENT 'BLABLA'
    +      """.stripMargin
    +
    +    val table = analyzeCreateTable(sql)
    +    assert(table.schema == new StructType()
    +      .add("id", "int")
    +      .add("name", "string", nullable = true, comment = "blabla"))
    +    assert(table.provider == Some(DDLUtils.HIVE_PROVIDER))
    +    assert(table.storage.locationUri == Some("/tmp/file"))
    +    assert(table.storage.properties == Map("my_prop" -> "1"))
    +    assert(table.comment == Some("BLABLA"))
    +
    +    assert(table.storage.inputFormat ==
    +      
Some("org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat"))
    +    assert(table.storage.outputFormat ==
    +      
Some("org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat"))
    +    assert(table.storage.serde ==
    +      Some("org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe"))
    +  }
    +
    +  test("create hive serde table with new syntax - with partition and 
bucketing") {
    +    val v1 = "CREATE TABLE t (c1 int, c2 int) USING hive PARTITIONED BY 
(c2)"
    +    val table = analyzeCreateTable(v1)
    +    assert(table.schema == new StructType().add("c1", "int").add("c2", 
"int"))
    +    assert(table.partitionColumnNames == Seq("c2"))
    +    // check the default formats
    +    assert(table.storage.serde == 
Some("org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe"))
    +    assert(table.storage.inputFormat == 
Some("org.apache.hadoop.mapred.TextInputFormat"))
    +    assert(table.storage.outputFormat ==
    +      Some("org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"))
    +
    +    val v2 = "CREATE TABLE t (c1 int, c2 int) USING hive CLUSTERED BY (c2) 
INTO 4 BUCKETS"
    +    val e = intercept[AnalysisException](analyzeCreateTable(v2))
    +    assert(e.message.contains("Cannot create bucketed Hive serde table"))
    --- End diff --
    
    Let's also have a test using both partitioning and bucketing.


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

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


Reply via email to