Copilot commented on code in PR #3129:
URL: https://github.com/apache/doris-website/pull/3129#discussion_r2573161840
##########
versioned_docs/version-3.x/sql-manual/sql-functions/scalar-functions/string-functions/append-trailing-char-if-absent.md:
##########
@@ -7,35 +7,89 @@
## Description
-Used to add a specific character (such as a space, a specific symbol, etc.) to
the end of a string if the character does not exist at the end of the string.
The function is to ensure that the string ends with a specific character.
+The APPEND_TRAILING_CHAR_IF_ABSENT function ensures that a string ends with a
specified character. If the character does not exist at the end of the string,
it is added; if it already exists, the string remains unchanged.
## Syntax
```sql
-APPEND_TRAILING_CHAR_IF_ABSENT ( <str> , <trailing_char> )
+APPEND_TRAILING_CHAR_IF_ABSENT(<str>, <trailing_char>)
```
## Parameters
-| Parameters | Description |
-|-------------------|-----------------------------|
-| `<str>` | Target string to be judged |
-| `<trailing_char>` | Character to be added to the end of the string (if the
character does not exist) |
+| Parameter | Description |
+| ------------------ | ----------------------------------------- |
+| `<str>` | The target string to process. Type: VARCHAR |
+| `<trailing_char>` | The character that must appear at the end of the string.
Type: VARCHAR |
-## Return value
+## Return Value
-Parameters The string after concatenation of `<str>` and `<trailing_char>` (if
`<trailing_char>` does not exist in `<str>`)
+Returns VARCHAR type:
+- If `<trailing_char>` does not exist at the end of `<str>`, returns the
concatenation of `<str>` and `<trailing_char>`
+- If `<trailing_char>` already exists at the end of `<str>`, returns the
original `<str>`
-## Example
+Special cases:
+- If any argument is NULL, returns NULL
+- If `<str>` is an empty string, returns `<trailing_char>`
-``` sql
-SELECT
APPEND_TRAILING_CHAR_IF_ABSENT('a','c'),APPEND_TRAILING_CHAR_IF_ABSENT('ac',
'c'),APPEND_TRAILING_CHAR_IF_ABSENT('ac', 'cd')
+## Examples
+
+1. Basic usage: Add character when it doesn't exist
+```sql
+SELECT APPEND_TRAILING_CHAR_IF_ABSENT('a', 'c');
+```
+```text
++------------------------------------------+
+| append_trailing_char_if_absent('a', 'c') |
++------------------------------------------+
+| ac |
++------------------------------------------+
```
-```text
-+------------------------------------------+-------------------------------------------+--------------------------------------------+
-| append_trailing_char_if_absent('a', 'c') |
append_trailing_char_if_absent('ac', 'c') |
append_trailing_char_if_absent('ac', 'cd') |
-+------------------------------------------+-------------------------------------------+--------------------------------------------+
-| ac | ac
| accd |
-+------------------------------------------+-------------------------------------------+--------------------------------------------+
+2. Character already exists, don't add
+```sql
+SELECT APPEND_TRAILING_CHAR_IF_ABSENT('ac', 'c');
+```
+```text
++-------------------------------------------+
+| append_trailing_char_if_absent('ac', 'c') |
++-------------------------------------------+
+| ac |
++-------------------------------------------+
+```
+
+3. Empty string handling
+```sql
+SELECT APPEND_TRAILING_CHAR_IF_ABSENT('', '/');
+```
+```text
++------------------------------------------+
+| append_trailing_char_if_absent('', '/') |
++------------------------------------------+
+| / |
++------------------------------------------+
+```
+
+4. NULL value handling
+```sql
+SELECT APPEND_TRAILING_CHAR_IF_ABSENT(NULL, 'c');
+```
+```text
++-------------------------------------------+
+| append_trailing_char_if_absent(NULL, 'c') |
++-------------------------------------------+
+| NULL |
++-------------------------------------------+
+```
+
+5. UTF-8 character
+```sql
+SELECT APPEND_TRAILING_CHAR_IF_ABSENT('acf', 'ṛ');
+```
+```text
++----------------------------------------------+
+| APPEND_TRAILING_CHAR_IF_ABSENT('acf', 'ṛ') |
Review Comment:
Inconsistent function name casing in example outputs. Most examples use
lowercase `append_trailing_char_if_absent` in the column headers (lines 43, 55,
67, 79), but example 5 uses uppercase `APPEND_TRAILING_CHAR_IF_ABSENT` (line
91).
For consistency with the other examples in this document, the UTF-8 example
should also use lowercase:
```text
| append_trailing_char_if_absent('acf', 'ṛ') |
```
```suggestion
| append_trailing_char_if_absent('acf', 'ṛ') |
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]