【Hive】Hive / HiveQL ~ HiveQL関数 / 文字列置換編 ~

■ はじめに

https://dk521123.hatenablog.com/entry/2020/02/25/231235

の続き。

今回は、 文字列置換の関数に絞って、知識を整理する

目次

【0】API仕様
【1】translate()
【2】replace()
【3】regexp_replace()

【0】API仕様

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-StringFunctions

【1】translate()

* fromとtoは1文字ごとに置き換える

構文

-- from の文字を to の文字に置き換えて input を変換
translate(
 string|char|varchar input,
 string|char|varchar from, 
 string|char|varchar to)

【2】replace()

* OLDの文字列をNEWの文字列に置き換える

構文

-- OLDの文字列をNEWの文字列に置き換えて A を変換
replace(
 string A,
 string OLD,
 string NEW)

【3】regexp_replace()

* 以下の関連記事を参照のこと

Hive / HiveQL ~ HiveQL関数・regexp_replace編 ~
https://dk521123.hatenablog.com/entry/2021/06/18/184713

参考文献

https://open-groove.net/hive/hive-string-functions/

以下のサイトが分かりやすい

https://blog.noraneko.work/2017-10-10-001/

関連記事

Hive / HiveQL ~ 入門編 ~
https://dk521123.hatenablog.com/entry/2020/02/25/231235
Hive / HiveQL ~ HiveQL関数・regexp_replace編 ~
https://dk521123.hatenablog.com/entry/2021/06/18/184713
Hive / HiveQL ~ HiveQL関数・文字列関数編 ~
https://dk521123.hatenablog.com/entry/2021/06/21/231033
Hive / HiveQL ~ HiveQL関数 / NULL関連編 ~
https://dk521123.hatenablog.com/entry/2021/06/22/213241
Hive / HiveQL ~ HiveQL / あれこれ編 ~
https://dk521123.hatenablog.com/entry/2020/03/04/225943
Hive / HiveQL ~ データをクリーニングする ~
https://dk521123.hatenablog.com/entry/2020/07/06/232350