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 1 year has passed since last update.

データ整備こぼれ話 vol.1: Presto で文字列を配列化して最後の要素を取得

Posted at

Python の list[-1] みたいなことをやりたい。
本来ドメイン的には Auto increment の数値が入っている場所に、過去データはカンマ区切りで複数の値が入っていたため (なので TEXT 型だった)、最後を取得して数値に用途で作成したスニペットです。

Athena presto

SELECT SPLIT('aaa,bbb,ccc', ',')[CARDINALITY(SPLIT('aaa,bbb,ccc', ','))]
>>> ccc

SELECT SPLIT('aaa', ',')[CARDINALITY(SPLIT('aaa', ','))]
>>> aaa
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?