【问题标题】:Unable to Create Table in Amazon Athena无法在 Amazon Athena 中创建表
【发布时间】:2020-05-12 18:18:55
【问题描述】:

我尝试在 Athena 中为我在 s3 中的嵌套 json 文件创建一个表,但收到错误:

第 1:8 行:输入“创建外部”时没有可行的替代方案(服务:amazonathena;状态代码:400;错误代码:invalidrequestexception;请求 ID:dcea57c7-b801-41a4-8edb-e42eb1608fea)

表名和字段似乎没问题,还附上了来自我的 s3 源的示例 json。参考了雅典娜的官方文档。另外,请告诉我是否以及如何从 Athena 的“创建表”向导中添加嵌套字段。

我的查询是:

    CREATE EXTERNAL TABLE bhaskar_clevertap(
         eventName string,
         ts bigint,
         eventProps struct<
         ContentCategory: string,
         Previous_screen: string,
         Platform: string,
         Category: string,
         Status: string,
         CT Source: string,
         CT Latitude: int,
         CT Longitude: int,
         Phone: bigint,
         ADID: string,
         Email: string,
         ScreenName: string,
         DBID: bigint,
         App_version: string,
         Device_ID: string,
         CT App Version: string>,
         profile struct< 
         objectId: string,
         all_identities: string,
         identity: bigint,
         platform: string,
         phone: bigint,
         name: string,
         email: string,
         push_token: string>,
         deviceInfo struct<
         osVersion: int,
         sdkVersion: int,
         make: string,
         model: string,
         appVersion: string,
         browser: string,
         dpi: int>,
         dimensions struct<
         width: int,
         height: int,
         unit: string> 
) 
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
 LOCATION 's3://clevertap-data-bhaskarapp/' 

示例 json 对象如下所示:

{
"eventName": "ScreenView",
"ts": 20200106073433,
"eventProps": {
    "ContentCategory": "ePaper",
    "Previous_screen": "",
    "Platform": "Android",
    "Category": "ePaper",
    "Status": "LoggedIn",
    "CT Source": "Mobile",
    "CT Latitude": 25.613659,
    "CT Longitude": 85.101135,
    "Phone": "+917678284002",
    "ADID": "fc2adc9b-6e31-459c-9bee-d6039a263e5c",
    "Email": "1008894402@dbcorp.in",
    "ScreenName": "ePaper_BIHAR_पटना_पटना_Page3",
    "DBID": "1008894402",
    "App_version": "6.1.0",
    "Device_ID": "3fccfa7749a8fba2",
    "CT App Version": "6.1.0"
},
"profile": {
    "objectId": "__gfc2adc9b6e31459c9beed6039a263e5c",
    "all_identities": ["7678284***", "1008894402@****"],
    "identity": "7678284***",
    "platform": "Android",
    "phone": 917678284***,
    "name": "NA",
    "email": "1008894402@****",
    "push_token": "fcm:dAI-w-gLwyk:APA91bE5E3pz63NMnV9rxqMwYTsOtQnmwjI8ZdElIX98fo0qiCPVnvekDwMMt27tAuI1F5PZmufw1OLpC_6V_hE_n_9eUVn8tF7EqA9MUu80wionD2FYtj*****FrSQDnDJoTFVZFmqg"
},
"deviceInfo": {
    "osVersion": "7.0",
    "sdkVersion": "30501",
    "make": "Xiaomi",
    "model": "Redmi Note 4",
    "appVersion": "6.1.0",
    "browser": "MobileApp",
    "dpi": 480,
    "dimensions": {
        "width": 69,
        "height": 121,
        "unit": "mm"
    }
}

}

请帮助我找出查询中的问题。

【问题讨论】:

    标签: sql hive amazon-athena


    【解决方案1】:

    Athena docs wrt 到对列名的限制不是很清楚。但是,在我看来,您的问题源于某些字段(列名)中有空格,例如CT SourceCT LatitudeCT LongitudeCT App Version。我设法通过用反引号包围这个名称来创建表格。

    CREATE EXTERNAL TABLE bhaskar_clevertap_2(
             eventName string,
             ts bigint,
             eventProps struct<
                ContentCategory: string,
                Previous_screen: string,
                Platform: string,
                Category: string,
                Status: string,
                `CT Source`: string,
                `CT Latitude`: int,
                `CT Longitude`: int,
                Phone: bigint,
                ADID: string,
                Email: string,
                ScreenName: string,
                DBID: bigint,
                App_version: string,
                Device_ID: string,
                `CT App Version`: string>,
             profile struct< 
                 objectId: string,
                 all_identities: string,
                 identity: bigint,
                 platform: string,
                 phone: bigint,
                 name: string,
                 email: string,
                 push_token: string>,
             deviceInfo struct<
                 osVersion: int,
                 sdkVersion: int,
                 make: string,
                 model: string,
                 appVersion: string,
                 browser: string,
                 dpi: int>,
             dimensions struct<
                 width: int,
                 height: int,
                 unit: string> 
    ) 
    ROW FORMAT SERDE 
        'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
    LOCATION 
        's3://clevertap-data-bhaskarapp/' 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-19
      • 2021-07-03
      • 1970-01-01
      • 2017-11-22
      • 1970-01-01
      • 2021-01-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多