Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc]Function class management statement #1847

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,37 @@ specific language governing permissions and limitations
under the License.
-->

## DROP-FUNCTION
## Description

### Name
Delete a custom function.

DROP FUNCTION

### Description

Delete a custom function. Function names and parameter types are exactly the same to be deleted.

grammar:
## Syntax

```sql
DROP [GLOBAL] FUNCTION function_name
(arg_type [, ...])
DROP [GLOBAL] FUNCTION <function_name> ( <arg_type>)
```

Parameter Description:
## Parameters

| Parameters | Instructions |
| -- | -- |
| `<function_name>` | The name of the function to delete |
| `<arg_type>` | To delete the argument list of the function |

- `function_name`: the name of the function to delete
- `arg_type`: the argument list of the function to delete
## Return Value

### Example
The statement can be deleted if executed successfully. Special cases:

1. Delete a function
- A function can be deleted only when its name and parameter types are the same

```sql
DROP FUNCTION my_add(INT, INT)
```
2. Delete a global function
## Examples

```sql
DROP GLOBAL FUNCTION my_add(INT, INT)
```
```sql
DROP FUNCTION my_add(INT, INT)
```

### Keywords
```sql
DROP GLOBAL FUNCTION my_add(INT, INT)
```

DROP, FUNCTION

### Best Practice
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,41 @@ specific language governing permissions and limitations
under the License.
-->

## SHOW-CREATE-FUNCTION
## Description

### Name
This statement is used to show the creation statement of a user-defined function

SHOW CREATE FUNCTION

### Description

This statement is used to display the creation statement of the user-defined function

grammar:
## Syntax

```sql
SHOW CREATE [GLOBAL] FUNCTION function_name(arg_type [, ...]) [FROM db_name]];
SHOW CREATE [<GLOBAL>] FUNCTION <function_name>(<arg_type>) [FROM db_name]];
```

illustrate:
1. `global`: The show function is global
2. `function_name`: The name of the function to display
3. `arg_type`: The parameter list of the function to display
4. If db_name is not specified, the current default db is used

**Note: the "global" keyword is only available after v2.0**

### Example
## Parameters

1. Show the creation statement of the specified function under the default db
| Parameters | Instructions |
| -- | -- |
| `<function_name>` | The name of the function to delete |
| `<arg_type>` | To delete the argument list of the function |

```sql
SHOW CREATE FUNCTION my_add(INT, INT)
```
2. Show the creation statement of the specified global function
## Return Value

```sql
SHOW CREATE GLOBAL FUNCTION my_add(INT, INT)
```
A custom function constructor clause

### Keywords
## Examples

SHOW, CREATE, FUNCTION

### Best Practice
```sql
SHOW CREATE FUNCTION add_one(INT)
```

```text
| Function Signature | Create Function
+--------------------+-------------------------------------------------------
| add_one(INT) | CREATE FUNCTION add_one(INT) RETURNS INT PROPERTIES (
"SYMBOL"="org.apache.doris.udf.AddOne",
"FILE"="file:///xxx.jar",
"ALWAYS_NULLABLE"="true",
"TYPE"="JAVA_UDF"
); |
+--------------------+-------------------------------------------------------
```
135 changes: 74 additions & 61 deletions docs/sql-manual/sql-statements/Show-Statements/SHOW-FUNCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,70 +24,63 @@ specific language governing permissions and limitations
under the License.
-->

## SHOW-FUNCTIONS
## Description

### Name
View all custom (system-provided) functions in the database.

SHOW FUNCTIONS
You need to have a 'SHOW' permission on this database

### Description

View all custom (system-provided) functions under the database. If the user specifies a database, then view the corresponding database, otherwise directly query the database where the current session is located

Requires `SHOW` permission on this database

grammar
## Syntax

```sql
SHOW [FULL] [BUILTIN] FUNCTIONS [IN|FROM db] [LIKE 'function_pattern']
SHOW [<FULL>] [<BUILTIN>] FUNCTIONS IN|FROM <db> [LIKE '<function_pattern>']
```

Parameters
## Parameters

>`full`: Indicates the detailed information of the display function
>`builtin`: Indicates the functions provided by the display system
>`db`: database name to query
>`function_pattern`: parameter used to filter function names
| Parameters | Instructions |
| -- | -- |
| `<FULL>` | indicates that detailed information about the function is displayed |
| `<BUILTIN>` | Indicates a function provided by the display system |
| `<db>` | Name of the database to be queried |
| `<function_pattern>` | Parameters used to filter function names |

grammar

```sql
SHOW GLOBAL [FULL] FUNCTIONS [LIKE 'function_pattern']
```
## Return Value

Parameters
Specifies the result of a function that matches the function name filter under the database

>`global`: Indicates it means that the show function is a global function
>`full`: Indicates the detailed information of the display function
>`function_pattern`: parameter used to filter function names

**Note: the "global" keyword is only available after v2.0**

### Example
## Examples

```sql
mysql> show full functions in testDb\G
**************************** 1. row ******************** ******
Signature: my_add(INT,INT)
Return Type: INT
Function Type: Scalar
show full functions in testDb
```

```text
*************************** 1. row ***************************
Signature: my_add(INT,INT)
Return Type: INT
Function Type: Scalar
Intermediate Type: NULL
Properties: {"symbol":"_ZN9doris_udf6AddUdfEPNS_15FunctionContextERKNS_6IntValES4_","object_file":"http://host:port/libudfsample.so","md5":"cfe7a362d10f3aaf6c49974ee0f1f878"}
**************************** 2. row ******************** ******
Signature: my_count(BIGINT)
Return Type: BIGINT
Function Type: Aggregate
Properties: {"symbol":"_ZN9doris_udf6AddUdfEPNS_15FunctionContextERKNS_6IntValES4_","object_file":"http://host:port/libudfsample.so","md5":"cfe7a362d10f3aaf6c49974ee0f1f878"}
*************************** 2. row ***************************
Signature: my_count(BIGINT)
Return Type: BIGINT
Function Type: Aggregate
Intermediate Type: NULL
Properties: { "object_file": "http: // host: port / libudasample.so", "finalize_fn": "_ZN9doris_udf13CountFinalizeEPNS_15FunctionContextERKNS_9BigIntValE", "init_fn": "_ZN9doris_udf9CountInitEPNS_15FunctionContextEPNS_9BigIntValE", "merge_fn": "_ZN9doris_udf10CountMergeEPNS_15FunctionContextERKNS_9BigIntValEPS2_", "md5": " 37d185f80f95569e2676da3d5b5b9d2f","update_fn":"_ZN9doris_udf11CountUpdateEPNS_15FunctionContextERKNS_6IntValEPNS_9BigIntValE"}
**************************** 3. row ******************** ******
Signature: id_masking(BIGINT)
Return Type: VARCHAR
Function Type: Alias
Properties: {"object_file":"http://host:port/libudasample.so","finalize_fn":"_ZN9doris_udf13CountFinalizeEPNS_15FunctionContextERKNS_9BigIntValE","init_fn":"_ZN9doris_udf9CountInitEPNS_15FunctionContextEPNS_9BigIntValE","merge_fn":"_ZN9doris_udf10CountMergeEPNS_15FunctionContextERKNS_9BigIntValEPS2_","md5":"37d185f80f95569e2676da3d5b5b9d2f","update_fn":"_ZN9doris_udf11CountUpdateEPNS_15FunctionContextERKNS_6IntValEPNS_9BigIntValE"}
*************************** 3. row ***************************
Signature: id_masking(BIGINT)
Return Type: VARCHAR
Function Type: Alias
Intermediate Type: NULL
Properties: {"parameter":"id","origin_function":"concat(left(`id`, 3), `****`, right(`id`, 4))"}
Properties: {"parameter":"id","origin_function":"concat(left(`id`, 3), `****`, right(`id`, 4))"}
```

3 rows in set (0.00 sec)
mysql> show builtin functions in testDb like 'year%';
```sql
show builtin functions in testDb like 'year%';
```

```text
+---------------+
| Function Name |
+---------------+
Expand All @@ -96,9 +89,34 @@ mysql> show builtin functions in testDb like 'year%';
| years_diff |
| years_sub |
+---------------+
2 rows in set (0.00 sec)
```


mysql> show global full functions\G;
## Syntax

```sql
SHOW GLOBAL [<FULL>] FUNCTIONS [LIKE '<function_pattern>']
```

## Parameters

| Parameters | Instructions |
| -- | -- |
| `<FULL>` | Displays detailed information about the function |
| `<function_pattern>` | Parameters used to filter function names |


## Return Value

Query the result of the function that matches the function name filtering in the database where the current session resides

## Examples

```sql
show global full functions
```

```text
*************************** 1. row ***************************
Signature: decimal(ALL, INT, INT)
Return Type: VARCHAR
Expand All @@ -111,22 +129,17 @@ Intermediate Type: NULL
Function Type: Alias
Intermediate Type: NULL
Properties: {"parameter":"id","origin_function":"concat(left(`id`, 3), `****`, right(`id`, 4))"}
2 rows in set (0.00 sec)

mysql> show global functions ;
```

```sql
show global functions
```

```text
+---------------+
| Function Name |
+---------------+
| decimal |
| id_masking |
+---------------+
2 rows in set (0.00 sec)

```

### Keywords

SHOW, FUNCTIONS

### Best Practice

Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,37 @@ specific language governing permissions and limitations
under the License.
-->

## DROP-FUNCTION

### Name

DROP FUNCTION

## 描述

删除一个自定义函数。函数的名字、参数类型完全一致才能够被删除
删除一个自定义函数。

语法:
## 语法

```sql
DROP [GLOBAL] FUNCTION function_name
(arg_type [, ...])
DROP [GLOBAL] FUNCTION <function_name> ( <arg_type>)
```

参数说明:
## 参数

- `function_name`: 要删除函数的名字
- `arg_type`: 要删除函数的参数列表
| 参数 | 说明 |
| -- | -- |
| `<function_name>` | 要删除函数的名字 |
| `<arg_type>` | 要删除函数的参数列表 |

## 举例
## 返回值

1. 删除掉一个函数
语句执行成功即可删除。特殊情况:

```sql
DROP FUNCTION my_add(INT, INT)
```
2. 删除掉一个全局函数
- 函数的名字、参数类型完全一致才能够被删除

```sql
DROP GLOBAL FUNCTION my_add(INT, INT)
```
## 举例

### Keywords
```sql
DROP FUNCTION my_add(INT, INT)
```

DROP, FUNCTION
```sql
DROP GLOBAL FUNCTION my_add(INT, INT)
```

### Best Practice

Loading