2015-05-12 35 views
1

當我執行這個Python代碼:allowLargeResults BigQuery中不工作

body = { 
    'configuration': { 
    'query': { 
     'destinationTable': { 
     'projectId': PROJECT_ID, 
     'tableId': 'new_items', 
     'datasetId': 'data_set' 
     }, 
     'writeDisposition': 'WRITE_TRUNCATE', 
     'allowLargeResults': True, 
     'query': 'select item from data_set.items where item not in (select item from data_set.old_items);' 
    } 
    } 
} 
job = service.jobs().insert(projectId = PROJECT_ID, body = body).execute() 

儘管有allowLargeResults設置爲true,我得到這個錯誤:

Response too large to return. Consider setting allowLargeResults to true in your job configuration.

誰能解釋這樣做的原因並給我一個關於如何擺脫這個錯誤的提示?

+0

可以請你修改你的問題來定義'服務' –

回答

1

我懷疑這個錯誤是由於查詢生成結果的中間階段之一。很可能它是NOT IN半連接中使用的SELECT。我能想到的唯一解決方法是重新編寫查詢作爲

select a.item from 
    data_set.items a 
    left outer join each 
    data_set.old_items b 
on a.item = b.item 
where b.item IS NULL 

的NOT IN的半連接子句不會讓每一個修改,但LEFT OUTER JOIN不會允許的話,這應該使查詢規模。

+0

謝謝你,你的解決方案的工作原理(儘管你的查詢需要一點修正),但我仍然不知道爲什麼allowLargeResults選項不工作,因爲它應該至。無論如何,運行你提出的緊湊查詢要好得多。 – Mig

+0

allowLargeResults適用於查詢的最終結果,但如果某些中間階段結果變得太大,它不起作用。這是每個修改器都有幫助的地方。 –