bigquery api の run_sync_query() メソッドのパラメータ "query_parameter" が機能しない?
--
python/google-cloud-bigquery==0.27.0 利用し client.run_sync_query() APIのquery_parameters を利用してみたのだが、バインド変数(@table_prefix
)が置換されない。スタックトレースを見る限り機能していないように見えるが、コードとして何か不備があるのか?
--
i tried to call run_sync_query api with query_parameters using python with google-cloud-bigquery==0.27.0.
I got error.
it seems it's not working.
According to stack-trace
the bind variable(@table_prefix) was kept without replacing values.
what should i fix my script?
myscript.py
query=""" #standardSQL select _table_suffix as suf from `dataset.@table_prefix*` where _table_suffix = '20171030' """ query_parameters=[ ScalarQueryParameter('table_prefix', 'STRING', mytable) ] result = self.client.run_sync_query(query=query, \ query_parameters=query_parmeters) result.run()
stacktrace
File "/usr/local/lib/python2.7/dist-packages/google/cloud/bigquery/query.py", line 387, in run method='POST', path=path, data=self._build_resource()) File "/usr/local/lib/python2.7/dist-packages/google/cloud/_http.py", line 293, in api_request raise exceptions.from_http_response(response) BadRequest: 400 POST https://www.googleapis.com/bigquery/v2/projects//queries: Invalid table name: dataset.@table_prefix*
--
"dataset" has table "mytable20171030".