繁体   English   中英

BigQuery STRING 列中允许使用哪些字符(出现“UDF 内存不足”错误)

[英]Which characters are allowed in a BigQuery STRING column (getting "UDF out of memory" error)

我有一个包含收据数据的 dataframe。 我的 dataframe 中的列text包含收据中的文本,当我尝试使用df.to_gbq(...)将数据上传到 BigQuery 时似乎是个问题,因为它会产生错误

GenericGBQException: Reason: 400 Resources exceeded during query execution: UDF out of memory.; Failed to read Parquet file /some/file. 
This might happen if the file contains a row that is too large,
 or if the total size of the pages loaded for the queried columns is too large.

根据错误消息,它似乎是一个“内存错误”,但我试图将每个文本中的所有字符转换为“a”(以查看字符串是否包含许多字符)但效果很好,即我怀疑就是它。

我试过将所有字符转换为utf8

df["text"] = df["text"].str.encode('utf-8') (因为根据文档他们应该是这样)但是失败了。 我试图用“”替换“\n”,但也失败了。

似乎我的收据文本中有一些值导致了一些麻烦,但很难弄清楚是什么(而且因为我有 ~3 mio 行,一次尝试每一行需要一段时间) - 是大查询表中有任何不允许的值吗?

事实证明, to_gbq中的chunksize并没有按照我认为的方式拆分块。 以块的形式手动循环 dataframe

CHUNKSIZE = 100_000
for i in range(0,df.shape[0]//CHUNKSIZE):
    print(i)
    df_temp = dataframe.iloc[i*CHUNKSIZE:(i+1)*CHUNKSIZE]
    df_temp.to_gbq(destination_table="Dataset.my_table",
    project_id = "my-project",
    if_exists="append",
    )

成功了(设置chunksize=100_000无效)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM