如何将 GCS 嵌套 JSON 放入 BQ 表中

问题描述 投票:0回答:1

我有根据嵌套 JSON 数据创建的 BQ 表。 但我面临架构错误“Field enb_location is type RECORD but has no schema” 下面是 BQ 表的架构和实际数据。你能帮助我在架构中缺少什么吗?

数据:

“enb_location”:{ “坐标”:[ -111.89160399999999, 40.873279 ], “crs”:{ “特性”: { “名称”:“EPSG:4326” }, “类型”:“名称” }, “类型”:“点” }

BQ表:

json google-cloud-platform google-bigquery
1个回答
0
投票

浏览此文档

通过下面的架构和命令,我能够加载数据。

您需要定义架构并运行如下

bq load
命令

bq --location=australia-southeast1 load --source_format=NEWLINE_DELIMITED_JSON YOUR_DATASET.PROJECT_ID gs://YOUR_GCS_LOCATION_WHERE_DATA/sample_json_data.json sample_json_schema.json --this is the schema file below on your local directory

[
  {
    "name": "end_location",
    "type": "RECORD",
    "mode": "NULLABLE",
    "fields": [
      {
        "name": "coordinates",
        "type": "FLOAT",
        "mode": "REPEATED"
      },
      {
        "name": "crs",
        "type": "RECORD",
        "mode": "NULLABLE",
        "fields": [
          {
            "name": "properties",
            "type": "RECORD",
            "mode": "NULLABLE",
            "fields": [
              {
                "name": "name",
                "type": "STRING",
                "mode": "NULLABLE"
              }
            ]
          },
          {
            "name": "type",
            "type": "STRING",
            "mode": "NULLABLE"
          }
        ]
      },
      {
        "name": "type",
        "type": "STRING",
        "mode": "NULLABLE"
      }
    ]
  }
]
© www.soinside.com 2019 - 2024. All rights reserved.