gatorsmile commented on a change in pull request #24486: [SPARK-27592][SQL] Set 
the bucketed data source table SerDe correctly
URL: https://github.com/apache/spark/pull/24486#discussion_r286560751
 
 

 ##########
 File path: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveMetastoreCatalogSuite.scala
 ##########
 @@ -273,4 +273,39 @@ class DataSourceWithHiveMetastoreCatalogSuite
     }
 
   }
+
+  test("Set the bucketed data source table SerDe correctly") {
+    val provider = "parquet"
+    withTable("t") {
+      spark.sql(
+        s"""
+          |CREATE TABLE t (c1 INT, c2 INT)
+          |USING $provider
+          |CLUSTERED BY (c1)
+          |SORTED BY (c1)
+          |INTO 2 BUCKETS
+        """.stripMargin)
+
+      val metadata = 
sessionState.catalog.getTableMetadata(TableIdentifier("t", Some("default")))
+
+      val hiveSerDe = HiveSerDe.sourceToSerDe(provider).get
+      assert(metadata.storage.serde === hiveSerDe.serde)
+      assert(metadata.storage.inputFormat === hiveSerDe.inputFormat)
+      assert(metadata.storage.outputFormat === hiveSerDe.outputFormat)
+
+      // It's a bucketed table at Spark side
+      assert(sql("DESC FORMATTED t").collect().containsSlice(
+        Seq(Row("Num Buckets", "2", ""), Row("Bucket Columns", "[`c1`]", ""))
+      ))
+
+      // It's not a bucketed table at Hive side
+      val client =
+        
spark.sharedState.externalCatalog.unwrapped.asInstanceOf[HiveExternalCatalog].client
+      val hiveSide = client.runSqlHive("DESC FORMATTED t")
 
 Review comment:
   also check the read results. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to