You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2023/10/20 01:23:14 UTC
[spark] branch master updated: [SPARK-45562][SQL][FOLLOWUP] Restore test case not require `rowTag` option
This is an automated email from the ASF dual-hosted git repository.
gurwls223 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 cd827d14bcb [SPARK-45562][SQL][FOLLOWUP] Restore test case not require `rowTag` option
cd827d14bcb is described below
commit cd827d14bcb2b7eae381d54e9f6961d474425fd0
Author: Jiaan Geng <be...@163.com>
AuthorDate: Fri Oct 20 10:23:02 2023 +0900
[SPARK-45562][SQL][FOLLOWUP] Restore test case not require `rowTag` option
### What changes were proposed in this pull request?
https://github.com/apache/spark/pull/43389 makes `rowTag` a required option. But the xml API (please see https://github.com/apache/spark/blob/7057952f6bc2c5cf97dd408effd1b18bee1cb8f4/sql/core/src/main/scala/org/apache/spark/sql/DataFrameReader.scala#L579C1-L579C1) is unrelated to `rowTag`.
This PR also improves some code and remove one line of unused code.
### Why are the changes needed?
Restore test case not require `rowTag` option.
### Does this PR introduce _any_ user-facing change?
'No'.
### How was this patch tested?
Exists test cases.
### Was this patch authored or co-authored using generative AI tooling?
'No'.
Closes #43455 from beliefer/SPARK-45562_followup.
Authored-by: Jiaan Geng <be...@163.com>
Signed-off-by: Hyukjin Kwon <gu...@apache.org>
---
.../src/main/scala/org/apache/spark/sql/catalyst/xml/XmlOptions.scala | 4 ++--
.../org/apache/spark/sql/execution/datasources/xml/XmlSuite.scala | 3 +--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/xml/XmlOptions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/xml/XmlOptions.scala
index d2c7b435fe6..763aa877ca0 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/xml/XmlOptions.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/xml/XmlOptions.scala
@@ -66,9 +66,9 @@ private[sql] class XmlOptions(
}
val compressionCodec = parameters.get(COMPRESSION).map(CompressionCodecs.getCodecClassName)
- val rowTagOpt = parameters.get(XmlOptions.ROW_TAG)
+ val rowTagOpt = parameters.get(XmlOptions.ROW_TAG).map(_.trim)
require(!rowTagRequired || rowTagOpt.isDefined, s"'${XmlOptions.ROW_TAG}' option is required.")
- val rowTag = rowTagOpt.getOrElse(XmlOptions.DEFAULT_ROW_TAG).trim
+ val rowTag = rowTagOpt.getOrElse(XmlOptions.DEFAULT_ROW_TAG)
require(rowTag.nonEmpty, s"'$ROW_TAG' option should not be an empty string.")
require(!rowTag.startsWith("<") && !rowTag.endsWith(">"),
s"'$ROW_TAG' should not include angle brackets")
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/xml/XmlSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/xml/XmlSuite.scala
index 23223b3e94e..7e5817bc3a0 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/xml/XmlSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/xml/XmlSuite.scala
@@ -1209,10 +1209,9 @@ class XmlSuite extends QueryTest with SharedSparkSession {
"<ROW><year>2015</year><make>Chevy</make><model>Volt</model><comment>No</comment></ROW>")
val xmlRDD = spark.sparkContext.parallelize(data)
val ds = spark.createDataset(xmlRDD)(Encoders.STRING)
- assert(spark.read.option("rowTag", "ROW").xml(ds).collect().length === 3)
+ assert(spark.read.xml(ds).collect().length === 3)
}
- import testImplicits._
test("from_xml basic test") {
val xmlData =
"""<parent foo="bar"><pid>14ft3</pid>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org