This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 3a84dfc776ae [SPARK-50786][SQL] Remove `removeWhitespace helper` for
DESCRIBE TABLE
3a84dfc776ae is described below
commit 3a84dfc776ae1f1ab2cde1f8d4076c9582b69069
Author: Amanda Liu <[email protected]>
AuthorDate: Fri Jan 10 09:39:50 2025 -0800
[SPARK-50786][SQL] Remove `removeWhitespace helper` for DESCRIBE TABLE
### What changes were proposed in this pull request?
When converting from `toJsonLinkedHashMap` result to `DESCRIBE TABLE`,
`removeWhitespace` helper is unnecessary. This PR removes the helper util to
ensure equivalent behavior of `DESCRIBE TABLE` output.
### Why are the changes needed?
Ensure backwards compatibility for `DESCRIBE TABLE`, after introduction of
`DESCRIBE TABLE AS JSON`
### Does this PR introduce _any_ user-facing change?
No, it maintains the original output of `DESCRIBE TABLE`.
### How was this patch tested?
Existing tests.
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #49433 from asl3/asl3/remove-describeremovewhitespace.
Authored-by: Amanda Liu <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
---
.../org/apache/spark/sql/catalyst/catalog/interface.scala | 14 +++++---------
.../test/resources/sql-tests/results/show-tables.sql.out | 2 ++
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/interface.scala
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/interface.scala
index 2ebfcf781b97..de828dfd3e28 100644
---
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/interface.scala
+++
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/interface.scala
@@ -63,29 +63,25 @@ trait MetadataMapSupport {
protected def jsonToString(
jsonMap: mutable.LinkedHashMap[String, JValue]):
mutable.LinkedHashMap[String, String] = {
- def removeWhitespace(str: String): String = {
- str.replaceAll("\\s+$", "")
- }
-
val map = new mutable.LinkedHashMap[String, String]()
jsonMap.foreach { case (key, jValue) =>
val stringValue = jValue match {
- case JString(value) => removeWhitespace(value)
+ case JString(value) => value
case JArray(values) =>
values.map(_.values)
.map {
- case str: String => quoteIdentifier(removeWhitespace(str))
- case other => removeWhitespace(other.toString)
+ case str: String => quoteIdentifier(str)
+ case other => other.toString
}
.mkString("[", ", ", "]")
case JObject(fields) =>
fields.map { case (k, v) =>
- s"$k=${removeWhitespace(v.values.toString)}"
+ s"$k=${v.values.toString}"
}
.mkString("[", ", ", "]")
case JInt(value) => value.toString
case JDouble(value) => value.toString
- case _ => removeWhitespace(jValue.values.toString)
+ case _ => jValue.values.toString
}
map.put(key, stringValue)
}
diff --git a/sql/core/src/test/resources/sql-tests/results/show-tables.sql.out
b/sql/core/src/test/resources/sql-tests/results/show-tables.sql.out
index af1bb75aef88..93c144477759 100644
--- a/sql/core/src/test/resources/sql-tests/results/show-tables.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/show-tables.sql.out
@@ -128,6 +128,7 @@ View Schema Mode: BINDING
Schema: root
|-- e: integer (nullable = true)
+
showdb show_t1 false Catalog: spark_catalog
Database: showdb
Table: show_t1
@@ -145,6 +146,7 @@ Schema: root
|-- c: string (nullable = true)
|-- d: string (nullable = true)
+
showdb show_t2 false Catalog: spark_catalog
Database: showdb
Table: show_t2
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]