【问题标题】:Export BigQuery table schema to JSON Schema将 BigQuery 表架构导出到 JSON 架构
【发布时间】:2020-03-22 21:55:51
【问题描述】:

可以将 bigquery 表架构导出到 JSON 文件,但生成的 JSON 文件是 bigquery 表架构而不是 JSON 架构。 我正在寻找一种使用基于此处可用标准的 bigquery 表生成 JSON 模式的方法:https://json-schema.org/

这看起来像这样:

{
  "definitions": {},
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://example.com/root.json",
  "type": "object",
  "title": "The Root Schema",
  "required": [
    "glossary"
  ],
  "properties": {
    "glossary": {
      "$id": "#/properties/glossary",
      "type": "object",
      "title": "The Glossary Schema",
      "required": [
        "title",
        "GlossDiv"
      ],
      "properties": {
        "title": {
          "$id": "#/properties/glossary/properties/title",
          "type": "string",
          "title": "The Title Schema",
          "default": "",
          "examples": [
            "example glossary"
          ],
          "pattern": "^(.*)$"
        },
        "GlossDiv": {
          "$id": "#/properties/glossary/properties/GlossDiv",
          "type": "object",
          "title": "The Glossdiv Schema",
          "required": [
            "title",
            "GlossList"
          ],
          "properties": {
            "title": {
              "$id": "#/properties/glossary/properties/GlossDiv/properties/title",
              "type": "string",
              "title": "The Title Schema",
              "default": "",
              "examples": [
                "S"
              ],
              "pattern": "^(.*)$"
            },
            "GlossList": {
              "$id": "#/properties/glossary/properties/GlossDiv/properties/GlossList",
              "type": "object",
              "title": "The Glosslist Schema",
              "required": [
                "GlossEntry"
              ],
              "properties": {
                "GlossEntry": {
                  "$id": "#/properties/glossary/properties/GlossDiv/properties/GlossList/properties/GlossEntry",
                  "type": "object",
                  "title": "The Glossentry Schema",
                  "required": [
                    "ID",
                    "SortAs",
                    "GlossTerm",
                    "Acronym",
                    "Abbrev",
                    "GlossDef",
                    "GlossSee"
                  ],
                  "properties": {
                    "ID": {
                      "$id": "#/properties/glossary/properties/GlossDiv/properties/GlossList/properties/GlossEntry/properties/ID",
                      "type": "string",
                      "title": "The Id Schema",
                      "default": "",
                      "examples": [
                        "SGML"
                      ],
                      "pattern": "^(.*)$"
                    },
                    "SortAs": {
                      "$id": "#/properties/glossary/properties/GlossDiv/properties/GlossList/properties/GlossEntry/properties/SortAs",
                      "type": "string",
                      "title": "The Sortas Schema",
                      "default": "",
                      "examples": [
                        "SGML"
                      ],
                      "pattern": "^(.*)$"
                    },
                    "GlossTerm": {
                      "$id": "#/properties/glossary/properties/GlossDiv/properties/GlossList/properties/GlossEntry/properties/GlossTerm",
                      "type": "string",
                      "title": "The Glossterm Schema",
                      "default": "",
                      "examples": [
                        "Standard Generalized Markup Language"
                      ],
                      "pattern": "^(.*)$"
                    },
                    "Acronym": {
                      "$id": "#/properties/glossary/properties/GlossDiv/properties/GlossList/properties/GlossEntry/properties/Acronym",
                      "type": "string",
                      "title": "The Acronym Schema",
                      "default": "",
                      "examples": [
                        "SGML"
                      ],
                      "pattern": "^(.*)$"
                    },
                    "Abbrev": {
                      "$id": "#/properties/glossary/properties/GlossDiv/properties/GlossList/properties/GlossEntry/properties/Abbrev",
                      "type": "string",
                      "title": "The Abbrev Schema",
                      "default": "",
                      "examples": [
                        "ISO 8879:1986"
                      ],
                      "pattern": "^(.*)$"
                    },
                    "GlossDef": {
                      "$id": "#/properties/glossary/properties/GlossDiv/properties/GlossList/properties/GlossEntry/properties/GlossDef",
                      "type": "object",
                      "title": "The Glossdef Schema",
                      "required": [
                        "para",
                        "GlossSeeAlso"
                      ],
                      "properties": {
                        "para": {
                          "$id": "#/properties/glossary/properties/GlossDiv/properties/GlossList/properties/GlossEntry/properties/GlossDef/properties/para",
                          "type": "string",
                          "title": "The Para Schema",
                          "default": "",
                          "examples": [
                            "A meta-markup language, used to create markup languages such as DocBook."
                          ],
                          "pattern": "^(.*)$"
                        },
                        "GlossSeeAlso": {
                          "$id": "#/properties/glossary/properties/GlossDiv/properties/GlossList/properties/GlossEntry/properties/GlossDef/properties/GlossSeeAlso",
                          "type": "array",
                          "title": "The Glossseealso Schema",
                          "items": {
                            "$id": "#/properties/glossary/properties/GlossDiv/properties/GlossList/properties/GlossEntry/properties/GlossDef/properties/GlossSeeAlso/items",
                            "type": "string",
                            "title": "The Items Schema",
                            "default": "",
                            "examples": [
                              "GML",
                              "XML"
                            ],
                            "pattern": "^(.*)$"
                          }
                        }
                      }
                    },
                    "GlossSee": {
                      "$id": "#/properties/glossary/properties/GlossDiv/properties/GlossList/properties/GlossEntry/properties/GlossSee",
                      "type": "string",
                      "title": "The Glosssee Schema",
                      "default": "",
                      "examples": [
                        "markup"
                      ],
                      "pattern": "^(.*)$"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

【问题讨论】:

    标签: google-bigquery


    【解决方案1】:

    BigQuery 不使用表架构的 json 架构标准。我发现两个项目的代码可用于从 json-schema 到 BigQuery 架构:

    您可以尝试使用这些项目作为参考来创建相反的转换。此外,您可以向 BigQuery 团队创建一个feature request,要求将 json-schema 标准作为输出格式选项。

    【讨论】:

    【解决方案2】:

    不,如果不为您编写程序,这是不可能的。

    我提出了一个要求此功能的功能请求。 https://issuetracker.google.com/issues/145308573

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-04
      • 2017-08-28
      • 2015-10-23
      • 2013-05-18
      • 2017-01-03
      • 1970-01-01
      • 1970-01-01
      • 2017-07-12
      相关资源
      最近更新 更多