2017-10-02 40 views
1

Google BigQueryでPythonクライアントライブラリを使用して単純なSELECT同期クエリを実行しています。私は目的のために使用していrun_sync_query()エラー403:PythonライブラリでBigQuery同期クエリを実行すると応答が大きすぎます

*** google.cloud.exceptions.Forbidden: 403 Response too large to return. Consider setting allowLargeResults to true

:私は次のエラーを取得しています。

私はそれが(unnecesaryものを取り去っ)されてやっている方法:

def run_query(query_str): 
    from google.cloud import bigquery 
    client = biquery.Client() 
    query = client.run_sync_query(query_str) 
    query.run() 
    return query.fetch_data() 

私はAPI documentationでパラメータallowLargeResultsがある承知していますが、私はからそのパラメータを設定する方法がわかりませんクライアントライブラリ。

答えて

0

あなたがそうのようにそれを設定することができます。

https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.allowLargeResults:あなたはallow_large_resultsを設定している場合しかし、あなたはまたに結果を書き込むために先テーブルを指定する必要があります

query.allow_large_results = True

https://github.com/GoogleCloudPlatform/google-cloud-python/blob/e716fbef3dc74e8853346426af356bad364f6637/bigquery/google/cloud/bigquery/job.py#L1090

[Optional] If true and query uses legacy SQL dialect, allows the query to produce arbitrarily large result tables at a slight cost in performance. Requires destinationTable to be set. For standard SQL queries, this flag is ignored and large results are always allowed. However, you must still set destinationTable when result size exceeds the allowed maximum response size.

+0

Pythonライブラリでは、デスティネーションテーブルはどのように設定されていますか? – adrpino

+0

これはGoogle自身にとってはとても簡単ですが、ここではあなたが行っています:https://googlecloudplatform.github.io/google-cloud-python/latest/bigquery/usage.html#querying-data-asynchronous –

+0

これは実際には使用していません同期クエリですが、 'run_async_query()'呼び出しは、私が使い終わったものです。 この場合、ジョブと宛先テーブルの名前を処理する必要があるため、これは推奨されていませんでした。同期ジョブを設定しようとしましたが、AFAIKは不可能です。 これはGoogleへの理解方法の問題ではありませんでした。 – adrpino

関連する問題