Athena query failing while using UNNEST(x) AS y

0

Hi, I am trying to run the following query using UNNEST

SELECT keywords FROM "query-annotation"."query_annotation" CROSS JOIN UNNEST(browse_nodes) AS single_browse_node WHERE marketplace_id=3 AND single_browse_node='x' LIMIT 50;

The above query is failing with the following error - SYNTAX_ERROR: line 3:28: Column 'single_browse_node' cannot be resolved

Although I am creating the unnest column with the given name but still it is failing. How do I fix this ? Any help would be really appreciated.

EDIT: If I try the following SELECT * FROM "query-annotation"."query_annotation" CROSS JOIN UNNEST(browse_nodes) AS single_browse_node WHERE marketplace_id=3 LIMIT 50;, this prints a column at the last with the heading _col21 having single_browse_node value in it and is not picking up the assigned name.

Thanks !!

已提問 2 年前檢視次數 1677 次
1 個回答
0

Try changing "UNNEST(browse_nodes) AS single_browse_node" to "UNNEST(browse_nodes) AS t(single_browse_node)".

It tells Athena to, for each row, flatten the array browse_nodes into a relation called t that has a column called single_browse_node. The alias t is arbitrary.

專家
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南