gpt4 book ai didi

python - bq.py 不是分页结果

转载 作者:太空狗 更新时间:2023-10-30 01:29:25 24 4
gpt4 key购买 nike

我们正在为 bq.py 编写包装器并且在处理大于 100k 行的结果集时遇到了一些问题。似乎在过去这工作得很好(我们遇到了与 Google BigQuery Incomplete Query Replies on Odd Attempts 相关的问题)。也许我不理解 doc page 上解释的限制?

例如:

#!/bin/bash

for i in `seq 99999 100002`;
do
bq query -q --nouse_cache --max_rows 99999999 "SELECT id, FROM [publicdata:samples.wikipedia] LIMIT $i" > $i.txt
j=$(cat $i.txt | wc -l)
echo "Limit $i Returned $j Rows"
done

产量(注意有 4 行格式):

Limit 99999 Returned   100003 Rows
Limit 100000 Returned 100004 Rows
Limit 100001 Returned 100004 Rows
Limit 100002 Returned 100004 Rows

在我们的包装器中,我们直接访问 API:

while row_count < total_rows:
data = client.apiclient.tabledata().list(maxResults=total_rows - row_count,
pageToken=page_token,
**table_dict).execute()

# If there are more results than will fit on a page,
# you will recieve a token for the next page
page_token = data.get('pageToken', None)

# How many rows are there across all pages?
total_rows = min(total_rows, int(data['totalRows'])) # Changed to use get(data[rows],0)
raw_page = data.get('rows', [])

在这种情况下,我们希望得到一个 token ,但没有返回任何 token 。

最佳答案

抱歉,我花了一些时间才回复您。

我能够识别存在于服务器端的错误,您最终会在 Java 客户端和 Python 客户端中看到它。我们计划在下周推出修复程序。一旦发生这种情况,您的客户就应该开始正确行事。

顺便说一句,我不确定您是否已经知道这一点,但是有一个完整的独立 python 客户端,您也可以使用它从 python 访问 API。我认为这可能比作为 bq.py 的一部分分发的客户端更方便。您将在此页面上找到指向它的链接: https://developers.google.com/bigquery/client-libraries

关于python - bq.py 不是分页结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19145587/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com