0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AWS Athena で配列の要素を Column にする

Posted at

一回 unnest にした結果を集計してカラムに戻してやることで実現した。

WITH dataset AS (
	SELECT ARRAY [1,2,3] AS items
)
SELECT MAX(CASE WHEN i = 1 THEN i END) AS one
	 , MAX(CASE WHEN i = 2 THEN i END) AS two
	 , MAX(CASE WHEN i = 3 THEN i END) AS three
FROM dataset
	     CROSS JOIN UNNEST(items) AS t(i)

こんな感じの結果になるよ。

スクリーンショット 2021-06-09 21.16.34.png

もっといい方法があったら教えて下さい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?