【问题标题】:@ sign at field name in json schema, Google BigQuery@ 在 json 架构中的字段名称处签名,Google BigQuery
【发布时间】:2017-02-19 11:26:53
【问题描述】:

我有一个问题,

我无法为要上传到 BigQuery 的 json 文件分配 json 架构,因为我的字段名称中有一个 @。

"Events": {
  "type": "object",
  "properties": {
    "Event": {
      "type": "object",
      "properties": {
        "@places": {
          "type": "object",
          "properties": {
            "id": {
              "type": "integer"
            },
            "comp_id": {
              "type": "string"
            },
            "manager_id": {
              "type": "integer"
            },
            "price": {
              "type": "integer"
            },
            "size": {
              "type": "integer"
            },
            "location": {
              "type": "integer"
            },
            "date": {
              "type": "object",
              "properties": {
                "locale": {
                  "type": "string"

【问题讨论】:

    标签: json schema google-bigquery


    【解决方案1】:

    尽管您放入 JSON 密钥中的任何字符串都是有效的,另请参阅 Q: Which characters are valid/invalid in a JSON key name?,但数据的消费者可能有特定的要求,即这实际上是不允许的。

    在您的情况下,BigQuery 是消费者,可能只是它不接受某些字符。如果是这种情况,除了从架构中删除特殊字符(在您的情况下为“@”)之外别无选择。

    【讨论】:

      【解决方案2】:

      JSON 文件中的字段将作为 BigQuery 表中的字段加载。 BigQuery 表的字段名称中不允许使用 @,因此您不能在 JSON 文件中使用它。

      来自 BQ 文档:

      名称只能包含字母(a-z、A-Z)、数字 (0-9) 或 下划线 (_),并且必须以字母或下划线开头。这 最大长度为 128 个字符。

      【讨论】:

      • 为此提供指向 Google 文档的链接会很好。我建议您在引用互联网来源时添加链接。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-30
      • 2023-03-18
      相关资源
      最近更新 更多