【问题标题】:Reading Nested XML and Loading to Redshift Efficiency读取嵌套 XML 并加载到 Redshift 效率
【发布时间】:2019-02-16 14:58:02
【问题描述】:

我有这个驻留在 S3 中的 XML 文件,我需要能够将其加载到 Redshift 中的各个表中。

我想检查一下使用 Scala 执行此操作的有效方法是什么?我对这个很陌生,想寻求一些建议。

我是创建一个单独的脚本来分块所需的元素,还是一个单独的脚本都从同一个 XML 文件中读取每个表的效率更高?或者 AWS Glue 是否能够处理这种嵌套的 XML 格式?

XML 数据

<Root>
<system>
    <head>
        <Store>123</Store>
        <storedate>2018-09-04</storedate>
    </head>
    <body>
        <SalesTxn>
            <Store>123</Store>
            <storedate>2018-09-04</storedate>               
            <txndetail>
                <sequence>1</sequence>                  
                <txngroup>
                    <Item>
                        <itemid>ABC</itemid>
                        <price>6.900000</price>
                        <quantity>1</quantity>

                    </Item>
                </txngroup>
            </txndetail>
            <txndetail>
                <sequence>2</sequence>      
                <txngroup>
                    <Item>
                        <itemid>DEF</itemid>
                        <price>6.890000</price>                         
                        <quantity>1</quantity>                          
                    </Item>
                </txngroup>
            </txndetail>                
            <total>
                <totalamount>13.79</totalamount>
            </total>
            <totalitems>
                <itemsnumber>2</itemsnumber>
            </totalitems>               
        </SalesTxn>
    </body>
</system>

期望的结果

事务级别

Store|StoreDate|ItemID|Price|Qty
123|2018-09-04|1|6.9|1
123|2018-09-04|2|6.89|1

收货水平

Store|StoreDate|TotalAmt|TotalQty
123|2018-09-04|13.79|2

【问题讨论】:

    标签: xml scala apache-spark amazon-redshift


    【解决方案1】:

    Google 搜索 Redshift+XML 似乎表明没有原生支持(所有结果都是各种流水线产品的帖子 - Alooma、Fivetran 等 - 提供将 XML 加载到 Redshift 的帮助)。事实上,Redshift 文档表明 XML 不受支持 ...

    两者都作为一种格式: https://docs.aws.amazon.com/redshift/latest/dg/c_unsupported-postgresql-datatypes.html

    作为一个函数: https://docs.aws.amazon.com/redshift/latest/dg/c_unsupported-postgresql-functions.html.

    考虑到这一点,最好更详细地了解您为此应用程序选择的 Redshift。或者,将Snowflake 视为一种对 XML 具有原生支持的选项可能会很有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-09
      相关资源
      最近更新 更多