Я пытаюсь получить схему таблицы, используя parse_table_schema_from_json
from apache_beam.io.gcp.bigquery import parse_table_schema_from_json
из здесь
Вот мой код:
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
Вот ошибкаЯ получаю:
Traceback (most recent call last):
File "test_get_schema.py", line 16, in <module>
getSchema("vauto_table_schema.json")
File "test_get_schema.py", line 13, in getSchema
table_schema = parse_table_schema_from_json(schema_data)
File "/home/usr/.local/lib/python2.7/site-packages/apache_beam/io/gcp/bigquery.py", line 269, in parse_table_schema_from_json
fields = [_parse_schema_field(f) for f in json_schema['fields']]
TypeError: list indices must be integers, not str
мой файл json выглядит так:
[
{
"name": "StockNumber",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "Product",
"type": "STRING",
"mode": "NULLABLE"
}
]
Чего мне не хватает?