尽管键是双引号,但键是保留关键字时,AWS Athena行强制转换失败 [英] AWS Athena row cast fails when key is a reserved keyword despite double quotes

查看:85
本文介绍了尽管键是双引号,但键是保留关键字时,AWS Athena行强制转换失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AWS Athena中的数据,并且正在尝试匹配某些输入数据的结构.这涉及嵌套结构,其中来自"是嵌套"的.是关键.这始终会引发错误.

I'm working with data in AWS Athena, and I'm trying to match the structure of some input data. This involves a nested structure where "from" is a key. This consistently throws errors.

我将问题缩小到以下事实:当您尝试将保留关键字用作行中的键时,Athena查询不起作用.下面的示例演示了此行为.

I've narrowed the issue down to the fact that Athena queries don't work when you try to use reserved keywords as keys in rows. The following examples demonstrate this behavior.

  1. 这种简单情况 SELECT CAST(ROW(1)AS ROW("from" INTEGER))失败,并出现以下错误: GENERIC_INTERNAL_ERROR:无法创建类JSON响应中的com.facebook.presto.execution.TaskInfo:[io.airlift.jaxrs.JsonMapperParsingException:Java类型无效的json

  1. This simple case, SELECT CAST(ROW(1) AS ROW("from" INTEGER)), fails with the following error: GENERIC_INTERNAL_ERROR: Unable to create class com.facebook.presto.execution.TaskInfo from JSON response: [io.airlift.jaxrs.JsonMapperParsingException: Invalid json for Java type

此简单案例成功运行: SELECT CAST(ROW(1)AS ROW("work"; INTEGER))

This simple case runs successfully: SELECT CAST(ROW(1) AS ROW("work" INTEGER))

Athena文档说,将保留的关键字括在双引号中,以便在SELECT语句中使用它们,但是上面的示例显示,当使用关键字作为行中的键时,查询仍然失败.

The Athena documentation says to enclose reserved keywords in double quotes to use them in SELECT statements, but the examples above show that queries still fail when using keywords as keys in rows.

我知道我还有其他选择,但这是迄今为止最方便的方法.在这种情况下可以使用保留关键字吗?

I know I have other options, but this way is by far the most convenient. Is there a way to use reserved keywords in this scenario?

推荐答案

正如Piotr在评论中提到的,这是一个Presto错误,并且鉴于它是几天前发布的,因此不太可能很快在Athena中修复.当Presto中的bug修复后,它可能会进入Athena的方式,我知道Athena团队有时会应用上游补丁,即使Athena基于Presto的旧版本也是如此.这可能并不足够重要,无法出现在他们的雷达上,但是如果您使用AWS打开支持通知单,则可能会发生(请确保您不需要任何解决方法,只需报告一个错误,否则您将获得一个警告.)支持人员花费太多时间试图帮助您关闭和重新打开设备.)

As Piotr mentions in a comment, this is a Presto bug and given that it was posted just days ago it's unlikely to be fixed in Athena anytime soon. When the bug is fixed in Presto it might find its way into Athena, I know the Athena team sometimes apply upstream patches even though Athena is based on an old version of Presto. This one might not be significant enough to appear on their radar, but if you open a support ticket with AWS it might happen (be sure to be clear that you don't need any workaround just report a bug, otherwise you'll have a support person spending way too much time trying to help you to turn things off and on again).

这篇关于尽管键是双引号,但键是保留关键字时,AWS Athena行强制转换失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆