【问题标题】:Generate Athena Tables for dynamic Partioned Folder structures on S3为 S3 上的动态分区文件夹结构生成 Athena 表
【发布时间】:2021-12-11 14:35:58
【问题描述】:

我在 S3 中有一个文件夹结构,看起来像这样。

root/
├── parter-1/
|   ├── config/
|   │   ├── config.json
|   │   └── feature.json
|   ├── customer-1
|   |   ├── config/
|   |   │   ├── config.json
|   |   │   └── feature.json
|   |   └── data/
|   |       ├── model-1/
|   |       │   ├── input/ 
|   |       |   |   ├── current/
|   |       |   |   |   ├── tbl1.csv
|   |       |   |   |   └── tbl2.csv
|   |       |   |   └── archive/
|   |       |   |   |   ├── aod=20211012/
|   |       |   |   |   ├── tbl1.csv
|   |       |   |   └── tbl2.csv
|   |       |   |       └── aod=20211210/
|   |       |   |           ├── tbl1.csv
|   |       |   |           └── tbl2.csv
|   |       │   └── output/
|   |       |       └──(Same as input)
|   |       ├── model-2/
|   |       │   └── (Same as model-1)
|   |       └── input.zip
|   ├── customer-2
|   .   └── (Same as customer-1)
|   .
|   | 
.   └── customer-n
.       └── (Same as customer-1)
└── partner-n
    └── (Same as partner-1)       

现在,我需要在 AWS 中生成 athena 表(用于 tb1、tbl2)等等。 具有 sanme tbl1.csv 的所有文件都具有相同的架构(列),对于 tbl2 等也是如此。我需要完全忽略目录中存在的配置文件夹、zip 文件和任何 json 文件。

最终的输出表需要是这样的。

**tbl1**
col_1 | col_2 | col_3 | partner |  customer | model | 



【问题讨论】:

    标签: amazon-web-services amazon-s3 amazon-athena


    【解决方案1】:

    这是不可能的。

    Amazon Athena 将自动包含location 给定的所有文件,包括所有子目录中的文件。

    【讨论】:

      【解决方案2】:

      请检查以下链接以创建表格

      Selecting specific files for athena

      Partition Athena query by S3 created date

      创建一个视图以将 tbl1 中的合作伙伴、客户和模型公开为 选择 , regexp_extract("$path", 'root/(.*)/') 合作伙伴, regexp_extract(....) 客户, regexp_extract(....) 模型 来自tbl1

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-19
        • 2019-03-12
        • 2012-11-10
        • 2015-08-31
        • 2016-06-14
        • 1970-01-01
        相关资源
        最近更新 更多