我试图使用parse_table_schema_from_json
from apache_beam.io.gcp.bigquery import parse_table_schema_from_json
获取表模式
来自here
这是我的代码:
def getSchema(pathToJSON):
with open(pathToJSON) as data_file:
schema_data = json.dumps(json.load(data_file))
table_schema = parse_table_schema_from_json(schema_data)
# print(table_schema)
return table_schema
以下是我得到的错误:
^{pr2}$我的json文件如下所示:
[
{
"name": "StockNumber",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "Product",
"type": "STRING",
"mode": "NULLABLE"
}
]
我错过了什么?在
你需要的是dict而不是list。像下面提到的那样修改函数和模式文件,然后再试一次
架构文件应该是
^{pr2}$相关问题 更多 >
编程相关推荐