Merge pull request #62592 from peter279k/add_try_base_usage

Document functions tryBase58Decode and  tryBase64Decode
This commit is contained in:
Nikita Mikhaylov 2024-04-25 11:30:37 +00:00 committed by GitHub
commit 7fef1d728d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1055,6 +1055,34 @@ Result:
Like `base58Decode` but returns an empty string in case of error.
**Syntax**
```sql
tryBase58Decode(encoded)
```
**Parameters**
- `encoded`: [String](../../sql-reference/data-types/string.md) column or constant. If the string is not a valid Base58-encoded value, returns an empty string in case of error.
**Returned value**
- A string containing the decoded value of the argument.
**Examples**
Query:
```sql
SELECT tryBase58Decode('3dc8KtHrwM') as res;
```
```response
┌─res─────┐
│ Encoded │
└─────────┘
```
## base64Encode
Encodes a String or FixedString as base64.
@ -1071,6 +1099,30 @@ Alias: `FROM_BASE64`.
Like `base64Decode` but returns an empty string in case of error.
**Syntax**
```sql
tryBase64Decode(encoded)
```
**Parameters**
- `encoded`: [String](../../sql-reference/data-types/string.md) column or constant. If the string is not a valid Base58-encoded value, returns an empty string in case of error.
**Examples**
Query:
```sql
SELECT tryBase64Decode('RW5jb2RlZA==') as res;
```
```response
┌─res─────┐
│ Encoded │
└─────────┘
```
## endsWith {#endswith}
Returns whether string `str` ends with `suffix`.