【问题标题】:Problems while creating bigquery table schema创建 bigquery 表架构时出现问题
【发布时间】:2015-05-18 11:21:06
【问题描述】:

使用 Google BigQuery 我需要手动创建一个表并加载 json 文件中包含的数据。我正在使用 BigQuery UI,但无法为数据定义架构,下面给出了相同的示例。问题来自下面的 json 数组。

{"Author": "Pranesh Nageshwar", "headline": "Train trashes crashed car", "charactercount": 1027, "dateLive": "2014-01-14", "keywords": ["train crash", "freight train", "online reporting page", "side road", "blue mountains", "new south wales", "australia", "blaxland", "new south wales", "australia", "crime stoppers", "springwood police station", "train tracks"], "id": "1226801299367"}

【问题讨论】:

  • 就像 Pentium10 说的......你有什么问题?你尝试了什么?在这一点上,您似乎不知道该怎么做,但还没有尝试过任何事情......
  • 因此,对于上面的示例,我尝试提供如下架构,但它不起作用:
  • 作者:STRING,标题:STRING,字符数:INTEGER,关键字:RECORD,id:STRING。它给我的错误是身份不明的类型“记录”。

标签: arrays json schema google-bigquery


【解决方案1】:

BigQuery 中的值数组表示为具有重复模式的字段。您想要的架构可能如下。如果您将其复制并粘贴到 Web UI 的框中,我认为它会起作用。

[
  {
    "name": "author",
    "type": "string"
  },
  {
    "name": "headline",
    "type": "string"
  },
  {
    "name": "charactercount",
    "type": "integer"
  },
  {
    "name": "dateLive",
    "type": "string",
  },
  {
    "name": "keywords",
    "type": "string",
    "mode": "repeated"
  },
  {
    "name": "id",
    "type": "string"
  }
]

【讨论】:

  • 我尝试了上述方法,但出现以下错误:字段:dateLive,无法将“2014-01-01”解析为时间戳。所需格式为 YYYY-MM-DD HH:MM[:SS[.SSSSSS]] 。这意味着控制甚至没有到达阵列。虽然如果我将它从时间戳类型更改为字符串,它会起作用。
  • 我已编辑我的答案以修复时间戳问题。很高兴它对你有用!
  • 感谢您的帮助,以上解决方案达到了目的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-29
  • 2018-07-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多