redShift:从S3复制命令Json数据 [英] Redshift: copy command Json data from s3

查看:34
本文介绍了redShift:从S3复制命令Json数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下JSON数据。

{  
   "recordid":"69",
   "recordTimestamp":1558087302591,
   "spaceId":"space-cd88557d",
   "spaceName":"Kirtipur",
   "partnerId":"Kirtipur",
   "eventType":"event-location-update",
   "eventlocationupdate":{  
      "event":{  
         "eventid":"event-qcTUrDAThkbPsXi438rRk",
         "userId":"",
         "tags":[  

         ],
         "mobile":"",
         "email":"",
         "gender":"OTHER",
         "firstName":"",
         "lastName":"",
         "postalCode":"",
         "optIns":[  

         ],
         "otherFields":[  

         ],
         "macAddress":"55:56:81🇧🇦a4:6d"
      },
      "location":{  
         "locationId":"location-bdfsfsf6a8d96",
         "name":"Kirtipur Office - wireless",
         "inferredLocationTypes":[  
            "NETWORK"
         ],
         "parent":{  
            "locationId":"location-c39ffc49",
            "name":"Kirtipur",
            "inferredLocationTypes":[  
               "vianet"
            ],
            "parent":{  
               "locationId":"location-8b47asdfdsf1c6a",
               "name":"Kirtipur",
               "inferredLocationTypes":[  
                  "ROOT"
               ]
            }
         }
      },
      "ssid":"",
      "rawUserId":"",
      "visitId":"visit-ca04ds5secb8d",
      "lastSeen":1558087081000,
      "deviceClassification":"",
      "mapId":"",
      "xPos":1.8595887,
      "yPos":3.5580606,
      "confidenceFactor":0.0,
      "latitude":0.0,
      "longitude":0.0
   }
}

我需要使用copy命令从S3存储桶加载它。我已将此文件上载到我的S3存储桶。

我使用过CSV文件的Copy命令,但没有使用过JSON文件的Copy命令。我研究了关于通过copy命令导入json的问题,但没有找到可靠的有帮助的命令示例。

我对复制命令使用了以下代码。

COPY vianet_raw_data 
from 's3://vianet-test/vianet.json' 
with credentials as '' 
format as json 'auto';

这没有插入任何数据。

有没有人能帮我处理这样的JSON的复制命令?

谢谢并问候

推荐答案

有两种情况(最有可能是第一种):

  1. 您希望AWS的自动选项从您在第2行中提供的S3加载。为此,您需要:
COPY vianet_raw_data 
from 's3://vianet-test/vianet.json' 
with credentials as '' 
json 'auto';
  1. 使用自定义JSON加载路径(即您不想自动加载所有路径)
COPY vianet_raw_data 
from 's3://vianet-test/vianet.json' 
with credentials as '' 
format as json 's3://vianet-test/vianet_PATHS.json';

此处,‘s3://vianet-test/Vianet_PATHS.json’包含您要查看的主位置的所有特定JSON。

参考:https://docs.aws.amazon.com/redshift/latest/dg/r_COPY_command_examples.html#r_COPY_command_examples-copy-from-json

这篇关于redShift:从S3复制命令Json数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆