Skip to content

Commit cdba396

Browse files
LuciferYangdongjoon-hyun
authored andcommitted
[SPARK-51401][SQL] Change ExplainUtils.generateFieldString to directly call QueryPlan.generateFieldString
### What changes were proposed in this pull request? This pr change `ExplainUtils.generateFieldString` to directly call `QueryPlan.generateFieldString` because these are identical methods. https://github.com/apache/spark/blob/4b4bdcfe1fe9bfd38030b855139a12fc55034083/sql/core/src/main/scala/org/apache/spark/sql/execution/ExplainUtils.scala#L300-L307 https://github.com/apache/spark/blob/4b4bdcfe1fe9bfd38030b855139a12fc55034083/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala#L789-L795 Meanwhile, this is a TODO left by nemanjapetr-db in SPARK-50739. ### Why are the changes needed? Remove duplicated code. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Pass Github Actions ### Was this patch authored or co-authored using generative AI tooling? No Closes #50169 from LuciferYang/SPARK-51401. Authored-by: yangjie01 <yangjie01@baidu.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
1 parent 6052121 commit cdba396

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/ExplainUtils.scala

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,8 @@ object ExplainUtils extends AdaptiveSparkPlanHelper {
297297
/**
298298
* Generate detailed field string with different format based on type of input value
299299
*/
300-
// TODO(nemanja.petrovic@databricks.com) Delete method as it is duplicated in QueryPlan.scala.
301-
def generateFieldString(fieldName: String, values: Any): String = values match {
302-
case iter: Iterable[_] if (iter.size == 0) => s"${fieldName}: []"
303-
case iter: Iterable[_] => s"${fieldName} [${iter.size}]: ${iter.mkString("[", ", ", "]")}"
304-
case str: String if (str == null || str.isEmpty) => s"${fieldName}: None"
305-
case str: String => s"${fieldName}: ${str}"
306-
case _ => throw new IllegalArgumentException(s"Unsupported type for argument values: $values")
307-
}
300+
def generateFieldString(fieldName: String, values: Any): String =
301+
QueryPlan.generateFieldString(fieldName, values)
308302

309303
/**
310304
* Given a input plan, returns an array of tuples comprising of :

0 commit comments

Comments
 (0)