SHOW FUNCTIONS

适用于:check marked yes Databricks SQL check marked yes Databricks Runtime

应用可选 regex 模式后返回函数列表。 Databricks SQL 支持大量函数。 SHOW FUNCTIONS 可以与 describe 函数配合使用,以便快速查找某个函数并了解其用法。 LIKE 子句是可选的,可确保与其他系统兼容。

语法

SHOW [ function_kind ] FUNCTIONS [ { FROM | IN } schema_name ]
                                 [ [ LIKE ] { function_name | regex_pattern } ]

function_kind
  { USER | SYSTEM | ALL }

参数

  • function_kind

    要搜索的函数的名称空间。 有效的名称空间为:

    • USER - 在用户定义的函数中查找函数。
    • SYSTEM - 在系统定义的函数中查找函数。
    • “ALL” -在用户和系统定义的函数之间查找函数。
  • schema_name

    适用于:check marked yes Databricks SQL check marked yes Databricks Runtime 10.3 及更高版本

    指定要在其中列出函数的架构。

  • function_name

    系统中现有函数的名称。 如果未提供 schema_name,则可以改为使用架构名称来限定函数名称。 如果 function_name 不符合资格,并且尚未指定 schema_name,则从当前架构解析函数。

  • regex_pattern

    用于筛选语句结果的正则表达式模式。

    • *| 字符外,该模式的工作方式类似于正则表达式。
    • 只有 * 则匹配 0 个或多个字符,| 用于分隔多个不同的正则表达式,其中任何一个表达式都可以匹配。
    • 在处理前,在输入模式中删除前导空格和尾随空格。 模式匹配不区分大小写。

示例

-- List a system function `trim` by searching both user defined and system
-- defined functions.
> SHOW FUNCTIONS trim;
     trim

-- List a system function `concat` by searching system defined functions.
> SHOW SYSTEM FUNCTIONS concat;
   concat

-- List a qualified function `max` from schema `salesdb`.
> SHOW SYSTEM FUNCTIONS IN salesdb max;
     max

-- List all functions starting with `t`
> SHOW FUNCTIONS LIKE 't*';
               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*';
   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]';
     tanh
     trim