SHOW FUNCTIONS
説明
オプションの正規表現パターンを適用した後に、関数のリストを返します。Spark がサポートする関数の数はかなり多いため、このステートメントは describe function と併用することで、関数を素早く見つけ、その使い方を理解するために使用できます。LIKE 句はオプションであり、他のシステムとの互換性のためにのみサポートされています。
構文
SHOW [ function_kind ] FUNCTIONS [ { FROM | IN } database_name ] [ LIKE regex_pattern ]
パラメータ
-
function_kind
検索対象となる関数の名前空間を指定します。有効な名前空間は以下の通りです。
- USER - ユーザー定義関数の中から関数を検索します。
- SYSTEM - システム定義関数の中から関数を検索します。
- ALL - ユーザー定義関数とシステム定義関数の両方の中から関数を検索します。
-
{ FROM
|IN } database_name関数のリストを取得するデータベース名を指定します。
-
regex_pattern
ステートメントの結果をフィルタリングするために使用される正規表現パターンを指定します。
*および|文字を除き、パターンは正規表現のように機能します。*単体は 0 文字以上の任意の文字に一致し、|は複数の異なる正規表現を区切るために使用され、いずれか一つに一致すればよいです。- 入力パターンは、処理前に先頭と末尾の空白がトリミングされます。パターンマッチはケースインセンシティブです。
例
-- List a system function `trim` by searching both user defined and system
-- defined functions.
SHOW FUNCTIONS trim;
+--------+
|function|
+--------+
| trim|
+--------+
-- List a system function `concat` by searching system defined functions.
SHOW SYSTEM FUNCTIONS concat;
+--------+
|function|
+--------+
| concat|
+--------+
-- List a qualified function `max` from database `salesdb`.
SHOW SYSTEM FUNCTIONS FROM salesdb LIKE 'max';
+--------+
|function|
+--------+
| max|
+--------+
-- List all functions starting with `t`
SHOW FUNCTIONS LIKE 't*';
+-----------------+
| function|
+-----------------+
| tan|
| tanh|
| timestamp|
| tinyint|
| to_csv|
| to_date|
| to_json|
| to_timestamp|
|to_unix_timestamp|
| to_utc_timestamp|
| transform|
| transform_keys|
| transform_values|
| translate|
| trim|
| trunc|
| typeof|
+-----------------+
-- List all functions starting with `yea` or `windo`
SHOW FUNCTIONS LIKE 'yea*|windo*';
+--------+
|function|
+--------+
| window|
| year|
+--------+
-- Use normal regex pattern to list function names that has 4 characters
-- with `t` as the starting character.
SHOW FUNCTIONS LIKE 't[a-z][a-z][a-z]';
+--------+
|function|
+--------+
| tanh|
| trim|
+--------+