Skip to content

Commit 567dd1d

Browse files
soyeric128Chasen-Zhang
authored andcommitted
TO_BINARY
1 parent 6d867db commit 567dd1d

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

docs/en/sql-reference/20-sql-functions/02-conversion-functions/to-binary.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
55

66
<FunctionDescription description="Introduced or updated: v1.2.673"/>
77

8-
Converts supported data types, including variant, bitmap, geometry, and geography, into their binary representation.
8+
Converts supported data types, including string, variant, bitmap, geometry, and geography, into their binary representation (hex format).
99

1010
See also: [TRY_TO_BINARY](try-to-binary.md)
1111

@@ -17,6 +17,18 @@ TO_BINARY( <expr> )
1717

1818
## Examples
1919

20+
This example converts a string to binary:
21+
22+
```sql
23+
SELECT TO_BINARY('Databend');
24+
25+
┌───────────────────────┐
26+
│ to_binary('Databend') │
27+
├───────────────────────┤
28+
│ 4461746162656E64 │
29+
└───────────────────────┘
30+
```
31+
2032
This example converts JSON data to binary:
2133

2234
```sql

docs/en/sql-reference/20-sql-functions/02-conversion-functions/try-to-binary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
55

66
<FunctionDescription description="Introduced or updated: v1.2.673"/>
77

8-
Attempts to convert supported data types, including variant, bitmap, geometry, and geography, into their binary representation, returning `NULL` if the conversion fails.
8+
An enhanced version of [TO_BINARY](to-binary.md) that converts an input expression to a binary value, returning `NULL` if the conversion fails instead of raising an error.
99

1010
See also: [TO_BINARY](to-binary.md)
1111

0 commit comments

Comments
 (0)