首页 > 解决方案 > df 上的 Athena 写入操作失败:神秘行为

问题描述

我正在尝试将数据帧写入pandasAthena DB。

preds是一个有 2590 行的 DF。

preds.to_sql('ds_forecast_results', ath_engine, schema=ath_info_['schema_name'], index=False, if_exists='append', method='multi')

失败并出现以下错误

ERROR:pyathena.common:Failed to execute query.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pyathena/common.py", line 250, in _execute
    **request
  [...]
  File "/usr/local/lib/python3.7/dist-packages/botocore/client.py", line 626, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.InvalidRequestException: An error occurred (InvalidRequestException) when calling the StartQueryExecution operation: 1 validation error detected: Value 'INSERT INTO [...]

下面的输出显示了 DF 的所有行,所以它不是很有帮助

有趣的是,通过拆分 DF 我没有这样的问题

preds_a = preds[0:1000]
preds_a.to_sql('ds_forecast_results', ath_engine, schema=ath_info_['schema_name'], index=False, if_exists='append', method='multi')
preds_b = preds[1000:]
preds_b.to_sql('ds_forecast_results', ath_engine, schema=ath_info_['schema_name'], index=False, if_exists='append', method='multi')

这怎么可能?如果存在有问题的行,则不可能编写两个 DF。

标签: pythonpandasamazon-athenapyathena

解决方案


推荐阅读