AWS Athena (Presto) 如何将地图转置为列 [英] AWS Athena (Presto) how to transpose map to columns
问题描述
AWS Athena 查询问题;
AWS Athena query question;
我的行中有一个嵌套映射,我想将其中的键转置为列.我可以像 items['label_a']
一样明确地命名列,但在这种情况下,键实际上是动态的...
I have a nested map in my rows, of which I would like to transpose the keys to columns.
I could name the columns explicitly like items['label_a']
, but in this case the keys are actually dynamic...
从这些行:
{id=1, items={label_a=foo, label_b=foo}}
{id=2, items={label_a=bar, label_c=bar}}
{id=3, items={label_b=baz, label_c=baz}}
我想要一张这样的桌子:
I would like to get a table like so:
| id | label_a | label_b | label_c |
------------------------------------
| 1 | foo | foo | |
| 2 | bar | | bar |
| 3 | | baz | baz |
在 aws athena (presto version 0.172) 中是否可行以及如何做到这一点?
Is that possible and how to do this in aws athena (presto version 0.172)?
谢谢!
推荐答案
由于在查询执行开始之前需要规划器知道输出列这一事实,这无法以动态方式实现.
This is not possible in a dynamic manner due to the fact that output columns need to be know to the planner before the query execution starts.
在这里查看之前的讨论:https://github.com/prestosql/presto/issues/2448 和 https://github.com/prestosql/presto/issues/1206.
See the previous discussion here: https://github.com/prestosql/presto/issues/2448 and https://github.com/prestosql/presto/issues/1206.
这篇关于AWS Athena (Presto) 如何将地图转置为列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!