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版本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屋!