Skip to content

Commit ca6c59e

Browse files
tejasapatilgatorsmile
authored andcommitted
[SPARK-20487][SQL] Display serde for HiveTableScan node in explained plan
## What changes were proposed in this pull request? This was a suggestion by rxin at #17780 (comment) ## How was this patch tested? - modified existing unit test - manual testing: ``` scala> hc.sql(" SELECT * FROM tejasp_bucketed_partitioned_1 where name = '' ").explain(true) == Parsed Logical Plan == 'Project [*] +- 'Filter ('name = ) +- 'UnresolvedRelation `tejasp_bucketed_partitioned_1` == Analyzed Logical Plan == user_id: bigint, name: string, ds: string Project [user_id#24L, name#25, ds#26] +- Filter (name#25 = ) +- SubqueryAlias tejasp_bucketed_partitioned_1 +- CatalogRelation `default`.`tejasp_bucketed_partitioned_1`, org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, [user_id#24L, name#25], [ds#26] == Optimized Logical Plan == Filter (isnotnull(name#25) && (name#25 = )) +- CatalogRelation `default`.`tejasp_bucketed_partitioned_1`, org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, [user_id#24L, name#25], [ds#26] == Physical Plan == *Filter (isnotnull(name#25) && (name#25 = )) +- HiveTableScan [user_id#24L, name#25, ds#26], CatalogRelation `default`.`tejasp_bucketed_partitioned_1`, org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, [user_id#24L, name#25], [ds#26] ``` Author: Tejas Patil <[email protected]> Closes #17806 from tejasapatil/add_serde. (cherry picked from commit 814a61a) Signed-off-by: gatorsmile <[email protected]>
1 parent 1405862 commit ca6c59e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreeNode.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,11 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product {
444444
case None => Nil
445445
case Some(null) => Nil
446446
case Some(any) => any :: Nil
447-
case table: CatalogTable => table.identifier :: Nil
447+
case table: CatalogTable =>
448+
table.storage.serde match {
449+
case Some(serde) => table.identifier :: serde :: Nil
450+
case _ => table.identifier :: Nil
451+
}
448452
case other => other :: Nil
449453
}.mkString(", ")
450454

sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveExplainSuite.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ class HiveExplainSuite extends QueryTest with SQLTestUtils with TestHiveSingleto
4343

4444
test("explain extended command") {
4545
checkKeywordsExist(sql(" explain select * from src where key=123 "),
46-
"== Physical Plan ==")
46+
"== Physical Plan ==",
47+
"org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe")
48+
4749
checkKeywordsNotExist(sql(" explain select * from src where key=123 "),
4850
"== Parsed Logical Plan ==",
4951
"== Analyzed Logical Plan ==",

0 commit comments

Comments
 (0)