Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

How to pass a Dataset[String] to spark xml #527

@mahkhalil

Description

@mahkhalil

We're trying to parse a XML column from a table using the latest version of spark-xml, so we extract that column into a Dataset[String]. We pass the converted dataset to the spark.read.xml() method, however our passed options doesn't seem to be used whenever we pass a Dataset[String], meaning that it ignores our passed options and it falls back to the default ones.

Here's how we convert the extracted column to a Dataset[String]
val xmlCol = srcDf.select("XMLRECORD").as[String]

Here's how we call spark-xml read() method

val df = spark.read
      .option("inferSchema", "false")
      .option("rowTag", "row")
      .option("columnNameOfCorruptedRecord", "bad_record")
      .schema(schema)
      .xml(xmlCol)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions