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

string-function changes #1841

Closed
wants to merge 6 commits 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 @@ -25,17 +25,19 @@ under the License.
-->


## trim-in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删掉这行

## 描述

删除输入字符串两端的多余空格
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

描述有些问题,当存在第二个参数时,不是删除空格

## 语法

`VARCHAR trim_in(VARCHAR str[, VARCHAR rhs])`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

语法中不要有类型,参数需要尖括号包裹。使用code block 而不是 inline code。函数名使用大写

Suggested change
`VARCHAR trim_in(VARCHAR str[, VARCHAR rhs])`
```sql
TRIM_IN( <str> [, <rhs> ] )
```


## 注意事项

当没有 `rhs` 参数时,将参数 `str` 中右侧和左侧开始部分连续出现的空格去掉;当有 `rhs` 参数时,在字符串的两端查找并移除 `rhs` 字符集合中的任何字符(不考虑顺序)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这句话直接写到描述里面。去掉注意事项章节



## 举例
## 示例

```sql
mysql> SELECT trim_in(' ab d ') str;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉prompt

Suggested change
mysql> SELECT trim_in(' ab d ') str;
SELECT trim_in(' ab d ') str;

Expand All @@ -44,15 +46,4 @@ mysql> SELECT trim_in(' ab d ') str;
+------+
| ab d |
+------+

mysql> SELECT trim_in('ababccaab','ab') str;
+------+
| str |
+------+
| cc |
Comment on lines -48 to -52
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个例子需要保留

+------+
```

## 关键词

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

## trim

## 描述
## 语法

`VARCHAR trim(VARCHAR str[, VARCHAR rhs])`
用于删除字符串两端的空格或指定字符

## 语法

```sql
trim( str [, VARCHAR rhs])
```

## 注意事项
当没有rhs参数时,将参数 str 中右侧和左侧开始部分连续出现的空格去掉,否则去掉rhs

## 举例
## 示例

```
```sql
mysql> SELECT trim(' ab d ') str;
+------+
| str |
Expand All @@ -50,5 +55,4 @@ mysql> SELECT trim('ababccaab','ab') str;
| cca |
+------+
```
### keywords
TRIM

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

## ucase

## 描述
## 语法

`VARCHAR ucase(VARCHAR str)`
用于将字符串转换为大写字母

## 别名

- upper

## 语法

```sql
ucase(string)
```

将参数中所有的字符串都转换成大写,此函数的另一个别名为[upper](./upper.md)。
### 示例

### keywords
UCASE
```sql
mysql> SELECT ucase("aBc123");
+-----------------+
| ucase('aBc123') |
+-----------------+
| ABC123 |
+-----------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,31 @@ specific language governing permissions and limitations
under the License.
-->

## url_decode


## 描述

将URL转换为解码字符串。
使用 UTF-8 编码完成所提供文本的 URL 编码。通常用于对作为 URL 的一部分传递的参数信息进行编码

## 语法

```sql
VARCHAR url_decode(VARCHAR url)
URL_DECODE(' STRING ')
```

### Parameters
## 必选参数

- url: 待解码的url
- STRING: 待编码的字符串

## 举例
## 示例

```
mysql> mysql> select url_decode('https%3A%2F%2Fdoris.apache.org%2Fzh-CN%2Fdocs%2Fsql-manual%2Fsql-functions%2Fstring-functions');
+------------------------------------------------+
| url_decode('https%3A%2F%2Fdoris.apache.org%2Fzh-CN%2Fdocs%2Fsql-manual%2Fsql-functions%2Fstring-functions') |
+------------------------------------------------+
| https://doris.apache.org/zh-CN/docs/sql-manual/sql-functions/string-functions |
+------------------------------------------------+
```
```sql

mysql> select URL_DECODE('Doris+Q%26A');
+---------------------------+
| url_decode('Doris+Q%26A') |
+---------------------------+
| Doris Q&A |
+---------------------------+

### keywords
URL DECODE
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
---
{
"title": "URL_ENCODE",
"title": "url_decode",
"language": "zh-CN"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->


## 描述

使用 UTF-8 编码完成所提供文本的 URL 编码。通常用于对作为 URL 的一部分传递的参数信息进行编码

## 语法

```sql
URL_ENCODE(' STRING ')
```

## 必选参数

- STRING: 待编码的字符串。

## 示例

```sql
mysql> select URL_ENCODE('Doris Q&A');
+-------------------------+
| url_encode('Doris Q&A') |
+-------------------------+
| Doris+Q%26A |
+-------------------------+

```

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

## uuid_to_int

## 描述

`LARGEINT uuid_to_int(VARCHAR uuid)`

对于输入的 uuid 字符串,返回一个 int128 表示。

## 举例
## 语法

```sql
uuid_to_int(VARCHAR uuid)
```


## 示例

```sql
mysql> select uuid_to_int("6ce4766f-6783-4b30-b357-bba1c7600348");
Expand All @@ -42,6 +46,3 @@ mysql> select uuid_to_int("6ce4766f-6783-4b30-b357-bba1c7600348");
| 95721955514869408091759290071393952876 |
+-----------------------------------------------------+
```

### keywords
UUID_TO_INT
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,25 @@ specific language governing permissions and limitations
under the License.
-->

## uuid

uuid

## 描述
## 语法

`VARCHAR uuid()`

返回一个随机的 uuid 字符串

## 语法

## 举例

```sql
uuid()
```

## 示例

```sql
mysql> select uuid();
+--------------------------------------+
| uuid() |
+--------------------------------------+
| 29077778-fc5e-4603-8368-6b5f8fd55c24 |
+--------------------------------------+

```

### keywords
UUID
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
{
"title": "UCASE",
"language": "zh-CN"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->


## 描述

用于将字符串转换为大写字母

## 别名

- upper

## 语法

```sql
ucase( str )
```

### 示例

```sql
mysql> SELECT ucase("aBc123");
+-----------------+
| ucase('aBc123') |
+-----------------+
| ABC123 |
+-----------------+
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
{
"title": "url_decode",
"language": "zh-CN"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->


## 描述

将URL转换为解码字符串。

## 语法

```sql
url_decode( url )
```

## 必选参数

- url: 待解码的url。

## 示例

```sql
mysql> select url_decode('https%3A%2F%2Fdoris.apache.org%2Fzh-CN%2Fdocs%2Fsql-manual%2Fsql-functions%2Fstring-functions');
+------------------------------------------------+
| url_decode('https%3A%2F%2Fdoris.apache.org%2Fzh-CN%2Fdocs%2Fsql-manual%2Fsql-functions%2Fstring-functions') |
+------------------------------------------------+
| https://doris.apache.org/zh-CN/docs/sql-manual/sql-functions/string-functions |
+------------------------------------------------+
```
Loading