Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.17.0
-
None
Description
- XML Format Reader
This plugin enables Drill to read XML files without defining any kind of schema.
-
- Configuration
Aside from the file extension, there is one configuration option:
- Configuration
- `dataLevel`: XML data often contains a considerable amount of nesting which is not necesarily useful for data analysis. This parameter allows you to set the nesting level
where the data actually starts. The levels start at `1`.
The default configuration is shown below:
```json
"xml":
```
-
- Data Types
All fields are read as strings. Nested fields are read as maps. Future functionality could include support for lists.
- Data Types
-
- Limitations: Schema Ambiguity
XML is a challenging format to process as the structure does not give any hints about the schema. For example, a JSON file might have the following record:
- Limitations: Schema Ambiguity
```json
"record" : {
"intField:" : 1,
"listField" : [1, 2],
"otherField" :
}
```
From this data, it is clear that `listField` is a `list` and `otherField` is a map. This same data could be represented in XML as follows:
```xml
<record>
<intField>1</intField>
<listField>
<value>1</value>
<value>2</value>
</listField>
<otherField>
<nestedField1>foo</nestedField1>
<nestedField2>bar</nestedField2>
</otherField>
</record>
```
This is no problem to parse this data. But consider what would happen if we encountered the following first:
```xml
<record>
<intField>1</intField>
<listField>
<value>2</value>
</listField>
<otherField>
<nestedField1>foo</nestedField1>
<nestedField2>bar</nestedField2>
</otherField>
</record>
```
In this example, there is no way for Drill to know whether `listField` is a `list` or a `map` because it only has one entry.
-
- Future Functionality
- *Build schema from XSD file or link*: One of the major challenges of this reader is having to infer the schema of the data. XML files do provide a schema although this is not
required. In the future, if there is interest, we can extend this reader to use an XSD file to build the schema which will be used to parse the actual XML file.
- *Infer Date Fields*: It may be possible to add the ability to infer data fields.
- *List Support*: Future functionality may include the ability to infer lists from data structures.