相關問題現有的表:Bigquery add columns to table schema using BQ command line tools的BigQuery:添加新列使用python BQ API
我要添加使用的BigQuery Python API BigQuery中的一個新列到現有的表(更新現有的表的模式)。
但是我的代碼似乎不工作。
這裏是我的代碼:
flow = flow_from_clientsecrets('secret_key_path', scope='my_scope')
storage = Storage('CREDENTIAL_PATH')
credentials = storage.get()
if credentials is None or credentials.invalid:
credentials = tools.run_flow(flow, storage, tools.argparser.parse_args([]))
http = httplib2.Http()
http = credentials.authorize(http)
bigquery_service = build('bigquery', 'v2', http=http)
tbObject = bigquery_service.tables()
query_body = {'schema': {'name':'new_column_name', 'type':'STRING'}}
tbObject.update(projectId='projectId', datasetId='datasetId', tableId='tableId', body=query_body).execute()
返回Provided schema doesn't match existing table's schema
錯誤。 任何人都可以給我一個可用的Python示例嗎? 非常感謝!
你應該提供完整的架構,不只是新的領域 –
米哈伊爾·你好,你是指現有表格的整個模式嗎? –
是的,有了新的領域。所以API將負責添加新的。但爲此發生整個架構需要呈現 –