Bigquery in Python: How to put the results of a query in a table? -


i started using bigquery in python2.7 , i'm having issues putting results of query in table.

my query:

query_data = {     'configuration': {         'query': {             'query': query             'destinationtable': {                 'projectid': project_id,                 'datasetid': dataset_id,                 'tableid': 'table_id'             },             'createdisposition': 'create_if_needed',             'writedisposition': 'write_truncate',             'allowlargeresults': true         },     } }  query_request.query(projectid=project_number,body=query_data).execute() 

according read in google bigquery documentation, destinationtable, createdisposition , writedisposition should ensure result of query ends in chosen bigquery table.

but doesn't , error:

httperror: https://www.googleapis.com/bigquery/v2/projects/project_id/queries?alt=json returned "required parameter missing">

does know how fix bug?


ps: 'query' works when use directly on google bigquery website, highly doubt problem there.

pps: @pentium10 able solve issue.

you can specifying destination table in query. need use jobs.insert api rather jobs.query call, , should specify writedisposition=write_append , fill out destination table.

here configuration like, if using raw api. if you're using python, python client should give accessors these same fields:

"configuration": {   "query": {     "query": "select count(*) foo.bar",     "destinationtable": {       "projectid": "my_project",       "datasetid": "my_dataset",       "tableid": "my_table"     },     "createdisposition": "create_if_needed",     "writedisposition": "write_append",   } } 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -