databricks / spark-xml

XML data source for Spark SQL and DataFrames
Apache License 2.0
505 stars 227 forks source link

Add attributes and values as key-value pairs when schema specifies MapType #504

Closed srowen closed 3 years ago

srowen commented 3 years ago

While spark-xml will never infer MapType for an element, it can parse an XML element and its children as a map if given to do so in a schema. Each child element and its value becomes a key-value pair in the map. However, currently, attributes of the parent node are ignored. It would be more consistent to add them as key-value pairs in the map as well, because if it were inferred as a struct, then attributes and values would appear as fields.