Github user wzhfy commented on a diff in the pull request:
https://github.com/apache/spark/pull/19757#discussion_r153184543
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveExplainSuite.scala
---
@@ -29,21 +30,30 @@ class HiveExplainSuite extends QueryTest with
SQLTestUtils with TestHiveSingleto
import testImplicits._
test("show cost in explain command") {
+ val explainCostCommand = "EXPLAIN COST SELECT * FROM src"
// For readability, we only show optimized plan and physical plan in
explain cost command
- checkKeywordsExist(sql("EXPLAIN COST SELECT * FROM src "),
+ checkKeywordsExist(sql(explainCostCommand),
"Optimized Logical Plan", "Physical Plan")
- checkKeywordsNotExist(sql("EXPLAIN COST SELECT * FROM src "),
+ checkKeywordsNotExist(sql(explainCostCommand),
"Parsed Logical Plan", "Analyzed Logical Plan")
- // Only has sizeInBytes before ANALYZE command
- checkKeywordsExist(sql("EXPLAIN COST SELECT * FROM src "),
"sizeInBytes")
- checkKeywordsNotExist(sql("EXPLAIN COST SELECT * FROM src "),
"rowCount")
+ withSQLConf(SQLConf.CBO_ENABLED.key -> "true") {
+ // Only has sizeInBytes before ANALYZE command
+ checkKeywordsExist(sql(explainCostCommand), "sizeInBytes")
+ checkKeywordsNotExist(sql(explainCostCommand), "rowCount")
- // Has both sizeInBytes and rowCount after ANALYZE command
- sql("ANALYZE TABLE src COMPUTE STATISTICS")
- checkKeywordsExist(sql("EXPLAIN COST SELECT * FROM src "),
"sizeInBytes", "rowCount")
+ // Has both sizeInBytes and rowCount after ANALYZE command
+ sql("ANALYZE TABLE src COMPUTE STATISTICS")
+ checkKeywordsExist(sql(explainCostCommand), "sizeInBytes",
"rowCount")
+ }
+
+ withSQLConf(SQLConf.CBO_ENABLED.key -> "false") {
+ // Don't show rowCount if cbo is disabled
+ checkKeywordsExist(sql(explainCostCommand), "sizeInBytes")
+ checkKeywordsNotExist(sql(explainCostCommand), "rowCount")
--- End diff --
yes, should I refresh it for robustness?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]