Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class XmlOptions(
val nullValue = parameters.getOrElse(NULL_VALUE, XmlOptions.DEFAULT_NULL_VALUE)
val columnNameOfCorruptRecord =
parameters.getOrElse(COLUMN_NAME_OF_CORRUPT_RECORD, defaultColumnNameOfCorruptRecord)
val ignoreSurroundingSpaces = getBool(IGNORE_SURROUNDING_SPACES, false)
val ignoreSurroundingSpaces = getBool(IGNORE_SURROUNDING_SPACES, true)
val parseMode = ParseMode.fromString(parameters.getOrElse(MODE, PermissiveMode.name))
val inferSchema = getBool(INFER_SCHEMA, true)
val rowValidationXSDPath = parameters.get(ROW_VALIDATION_XSD_PATH).orNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ class XmlSuite extends QueryTest with SharedSparkSession {
.collect()

assert(results(0) === Row("alice", "35"))
assert(results(1) === Row("bob", " "))
assert(results(1) === Row("bob", ""))
assert(results(2) === Row("coc", "24"))
}

Expand Down Expand Up @@ -818,7 +818,7 @@ class XmlSuite extends QueryTest with SharedSparkSession {
assert(result(0) === Row(Row(null)))
assert(result(1) === Row(Row(Row(null, null))))
assert(result(2) === Row(Row(Row("E", null))))
assert(result(3) === Row(Row(Row("E", " "))))
assert(result(3) === Row(Row(Row("E", ""))))
assert(result(4) === Row(Row(Row("E", ""))))
}

Expand Down Expand Up @@ -1146,18 +1146,18 @@ class XmlSuite extends QueryTest with SharedSparkSession {
.option("inferSchema", true)
.xml(getTestResourcePath(resDir + "mixed_children.xml"))
val mixedRow = mixedDF.head()
assert(mixedRow.getAs[Row](0) === Row(List(" issue ", " text ignored "), " lorem "))
assert(mixedRow.getString(1) === " ipsum ")
assert(mixedRow.getAs[Row](0) === Row(List("issue", "text ignored"), "lorem"))
assert(mixedRow.getString(1) === "ipsum")
}

test("test mixed text and complex element children") {
val mixedDF = spark.read
.option("rowTag", "root")
.option("inferSchema", true)
.xml(getTestResourcePath(resDir + "mixed_children_2.xml"))
assert(mixedDF.select("foo.bar").head().getString(0) === " lorem ")
assert(mixedDF.select("foo.bar").head().getString(0) === "lorem")
assert(mixedDF.select("foo.baz.bing").head().getLong(0) === 2)
assert(mixedDF.select("missing").head().getString(0) === " ipsum ")
assert(mixedDF.select("missing").head().getString(0) === "ipsum")
}

test("test XSD validation") {
Expand Down Expand Up @@ -1721,7 +1721,7 @@ class XmlSuite extends QueryTest with SharedSparkSession {
assert(result(1).getAs[String]("_attr") == "attr1"
&& result(1).getAs[String]("_VALUE") == "value2")
// comments aren't included in valueTag
assert(result(2).getAs[String]("_VALUE") == "\n value3\n ")
assert(result(2).getAs[String]("_VALUE") == "value3")
}
}

Expand Down