python - df 上的 Athena 写入操作失败:神秘行为
问题描述
我正在尝试将数据帧写入pandas
Athena 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。
解决方案
推荐阅读
- regex - 正则表达式 - 获取 2 个字符串之间的字符串
- java - 如何在不使用集合或哈希集但使用给定哈希集表的情况下获得两个集合的并集?
- amazon-web-services - 无法从笔记本电脑访问公共子网中的极光集群
- ubuntu-16.04 - cloud-config 似乎没有运行脚本-per-once、runcmd 或 per-boot 模块
- javascript - vue pwa webpack axios process.env没有转义url和崩溃的webpack
- javascript - 将 div 设置为右侧动画然后动态添加新 div 时出现问题
- sql-server - 带有返回对象的 Web api 中的存储过程中的语法不正确
- javascript - 函数参数可以使用数组方法吗?
- ruby - NameError:在尝试测试调用位于方法中的变量的输出时,RSpec 中未定义
- c++ - 我正面临 .cmake 文件的问题如何解决?