首页 > 解决方案 > 如何通过 Glue 在 AWS Athena 中查询嵌套的 XML 文件

问题描述

我希望嵌套的 XML 文件使用 AWS 胶水从 AWS Athena 进行查询。

<Files>
<File>
<Charges>
<charge>
<FRNo>99988881111</FRNo>
<amount>25.0</amount>
<Date>2019-02-25</Date>
<chargeType>Recur</chargeType>
<phoneNo>4444000012</phoneNo>
</charge>

<charge>
<FRNo>99988881111</FRNo>
<amount>40.0</amount>
<Date>2019-02-25</Date>
<chargeType>Recur</chargeType>
<phoneNo>4444000012</phoneNo>
</charge>

</Charges>


<FRNo>99988881111</FRNo>
<address>New YORK</address>
<amount>111</amount>
<DN>100000</DN>
 <name>Rite</name>
<phoneNo>4444000012</phoneNo>
<tax>8.0</tax>
</File>
</Files>

像这样,我有一些 10k 记录。我认为我们必须对 ETL 工作进行一些修改。让我知道任何其他信息。

标签: amazon-web-servicespysparketlamazon-athenaaws-glue

解决方案


Currently, Amazon Athena does not support the XML file format. You may find the list of supported formats here: Supported SerDes and Data Formats - Amazon Athena

Since AWS Glue supports XML as an ETL input format (https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-format.html), you may first convert your data from XML to JSON and then query the JSON data using Athena.


推荐阅读