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 d2c7b435fe63f..763aa877ca0f1 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 23223b3e94e06..7e5817bc3a0af 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 {
"2015ChevyVoltNo
")
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 =
"""14ft3