This is an automated email from the ASF dual-hosted git repository.

luzhijing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git


The following commit(s) were added to refs/heads/master by this push:
     new 00fe6b21dd41 [doc](docs) Add example and description in sql function 
cast (#437)
00fe6b21dd41 is described below

commit 00fe6b21dd411dad83b4e2b990732d7aaa2ce6b9
Author: Qifeng <[email protected]>
AuthorDate: Wed Mar 20 22:42:50 2024 +0800

    [doc](docs) Add example and description in sql function cast (#437)
---
 docs/sql-manual/sql-functions/cast.md              | 38 +++++++++++--------
 .../version-2.1/sql-manual/sql-functions/cast.md   | 44 +++++++++++++---------
 .../version-2.1/sql-manual/sql-functions/cast.md   | 39 +++++++++++--------
 3 files changed, 74 insertions(+), 47 deletions(-)

diff --git a/docs/sql-manual/sql-functions/cast.md 
b/docs/sql-manual/sql-functions/cast.md
index d4b8484f1263..eee48771b25d 100644
--- a/docs/sql-manual/sql-functions/cast.md
+++ b/docs/sql-manual/sql-functions/cast.md
@@ -3,6 +3,7 @@
     "title": "CAST",
     "language": "en"
 }
+
 ---
 
 <!-- 
@@ -25,30 +26,33 @@ under the License.
 -->
 
 ## CAST
+
 ### Description
 
+The `CAST` function is used for data type conversion in SQL queries. It is 
typically used to convert one data type into another, such as converting a 
string to an integer, converting an integer to a string, and so on.
+
 #### Syntax
 
-`T cast (input as Type)`
+`CAST (src_type as dst_type)`
 
-Converts input to the specified type
+Converts the src_type to the specified dst_type.
 
-### example
+### Example
 
 1. Turn constant, or a column in a table
 
-```
-mysql> select cast (1 as BIGINT);
-+-------------------+
-| CAST(1 AS BIGINT) |
-+-------------------+
-|                 1 |
-+-------------------+
+```mysql
+mysql> select cast('1234' as int);
++---------------------+
+| cast('1234' as INT) |
++---------------------+
+|                1234 |
++---------------------+
 ```
 
 2. Transferred raw data
 
-```
+```shell
 curl --location-trusted -u root: -T ~/user_data/bigint -H "columns: tmp_k1, 
k1=cast(tmp_k1 as BIGINT)"  http://host:port/api/test/bigint/_stream_load
 ```
 
@@ -56,9 +60,11 @@ curl --location-trusted -u root: -T ~/user_data/bigint -H 
"columns: tmp_k1, k1=c
 
 If you want to force this type of raw data cast to int. Look at the following 
words:
 
-```
+```shell
 curl --location-trusted -u root: -T ~/user_data/bigint -H "columns: tmp_k1, 
k1=cast(cast(tmp_k1 as DOUBLE) as BIGINT)"  
http://host:port/api/test/bigint/_stream_load
+```
 
+```mysql
 mysql> select cast(cast ("11.2" as double) as bigint);
 +----------------------------------------+
 | CAST(CAST('11.2' AS DOUBLE) AS BIGINT) |
@@ -67,7 +73,7 @@ mysql> select cast(cast ("11.2" as double) as bigint);
 +----------------------------------------+
 1 row in set (0.00 sec)
 
-For the DECIMALV3 type, the cast operation performs rounding half up.
+# For the DECIMALV3 type, the cast operation performs rounding half up.
 mysql> select cast (1.115 as DECIMALV3(16, 2));
 +---------------------------------+
 | cast(1.115 as DECIMALV3(16, 2)) |
@@ -75,5 +81,7 @@ mysql> select cast (1.115 as DECIMALV3(16, 2));
 |                            1.12 |
 +---------------------------------+
 ```
-### keywords
-CAST
+
+### Keywords
+
+CAST
\ No newline at end of file
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/cast.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/cast.md
index d6e340e254b8..4fdbdf07134f 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/cast.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/cast.md
@@ -3,6 +3,7 @@
     "title": "CAST",
     "language": "zh-CN"
 }
+
 ---
 
 <!-- 
@@ -25,29 +26,33 @@ under the License.
 -->
 
 ## CAST
-### description
+
+### Description
+
+`CAST` 函数用于 SQL 查询中的数据类型转换。 它通常用于将一种数据类型转换为另一种数据类型,例如将字符串转换为整数、将整数转换为字符串等。
+
 #### Syntax
 
-`T cast (input as Type)`
+`CAST (src_type as dst_type)`
 
-将 input 转成 指定的 Type类型
+将 src_type 转成指定的 dst_type 类型
 
-### example
+### Example
 
 1. 转常量,或表中某列
 
-```
-mysql> select cast (1 as BIGINT);
-+-------------------+
-| CAST(1 AS BIGINT) |
-+-------------------+
-|                 1 |
-+-------------------+
+```mysql
+mysql> select cast('1234' as int);
++---------------------+
+| cast('1234' as INT) |
++---------------------+
+|                1234 |
++---------------------+
 ```
 
 2. 转导入的原始数据
 
-```
+```shell
 curl --location-trusted -u root: -T ~/user_data/bigint -H "columns: tmp_k1, 
k1=cast(tmp_k1 as BIGINT)"  http://host:port/api/test/bigint/_stream_load
 ```
 
@@ -55,9 +60,11 @@ curl --location-trusted -u root: -T ~/user_data/bigint -H 
"columns: tmp_k1, k1=c
 
 如果想强制将这种类型的原始数据 cast to int 的话。请看下面写法:
 
-```
+```shell
 curl --location-trusted -u root: -T ~/user_data/bigint -H "columns: tmp_k1, 
k1=cast(cast(tmp_k1 as DOUBLE) as BIGINT)"  
http://host:port/api/test/bigint/_stream_load
+```
 
+```mysql
 mysql> select cast(cast ("11.2" as double) as bigint);
 +----------------------------------------+
 | CAST(CAST('11.2' AS DOUBLE) AS BIGINT) |
@@ -67,8 +74,9 @@ mysql> select cast(cast ("11.2" as double) as bigint);
 1 row in set (0.00 sec)
 ```
 
-对于DECIMALV3类型,cast会进行四舍五入
-```
+对于DECIMALV3类型,`CAST` 会进行四舍五入:
+
+```mysql
 mysql> select cast (1.115 as DECIMALV3(16, 2));
 +---------------------------------+
 | cast(1.115 as DECIMALV3(16, 2)) |
@@ -76,5 +84,7 @@ mysql> select cast (1.115 as DECIMALV3(16, 2));
 |                            1.12 |
 +---------------------------------+
 ```
-### keywords
-CAST
+
+### Keywords
+
+CAST
\ No newline at end of file
diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/cast.md 
b/versioned_docs/version-2.1/sql-manual/sql-functions/cast.md
index d4b8484f1263..dbd5d8d6b09f 100644
--- a/versioned_docs/version-2.1/sql-manual/sql-functions/cast.md
+++ b/versioned_docs/version-2.1/sql-manual/sql-functions/cast.md
@@ -3,6 +3,8 @@
     "title": "CAST",
     "language": "en"
 }
+
+
 ---
 
 <!-- 
@@ -25,30 +27,33 @@ under the License.
 -->
 
 ## CAST
+
 ### Description
 
+The `CAST` function is used for data type conversion in SQL queries. It is 
typically used to convert one data type into another, such as converting a 
string to an integer, converting an integer to a string, and so on.
+
 #### Syntax
 
-`T cast (input as Type)`
+`CAST (src_type as dst_type)`
 
-Converts input to the specified type
+Converts the src_type to the specified dst_type.
 
-### example
+### Example
 
 1. Turn constant, or a column in a table
 
-```
-mysql> select cast (1 as BIGINT);
-+-------------------+
-| CAST(1 AS BIGINT) |
-+-------------------+
-|                 1 |
-+-------------------+
+```mysql
+mysql> select cast('1234' as int);
++---------------------+
+| cast('1234' as INT) |
++---------------------+
+|                1234 |
++---------------------+
 ```
 
 2. Transferred raw data
 
-```
+```shell
 curl --location-trusted -u root: -T ~/user_data/bigint -H "columns: tmp_k1, 
k1=cast(tmp_k1 as BIGINT)"  http://host:port/api/test/bigint/_stream_load
 ```
 
@@ -56,9 +61,11 @@ curl --location-trusted -u root: -T ~/user_data/bigint -H 
"columns: tmp_k1, k1=c
 
 If you want to force this type of raw data cast to int. Look at the following 
words:
 
-```
+```shell
 curl --location-trusted -u root: -T ~/user_data/bigint -H "columns: tmp_k1, 
k1=cast(cast(tmp_k1 as DOUBLE) as BIGINT)"  
http://host:port/api/test/bigint/_stream_load
+```
 
+```mysql
 mysql> select cast(cast ("11.2" as double) as bigint);
 +----------------------------------------+
 | CAST(CAST('11.2' AS DOUBLE) AS BIGINT) |
@@ -67,7 +74,7 @@ mysql> select cast(cast ("11.2" as double) as bigint);
 +----------------------------------------+
 1 row in set (0.00 sec)
 
-For the DECIMALV3 type, the cast operation performs rounding half up.
+# For the DECIMALV3 type, the cast operation performs rounding half up.
 mysql> select cast (1.115 as DECIMALV3(16, 2));
 +---------------------------------+
 | cast(1.115 as DECIMALV3(16, 2)) |
@@ -75,5 +82,7 @@ mysql> select cast (1.115 as DECIMALV3(16, 2));
 |                            1.12 |
 +---------------------------------+
 ```
-### keywords
-CAST
+
+### Keywords
+
+CAST
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to