yiguolei commented on code in PR #4380:
URL: https://github.com/apache/doris-website/pull/4380#discussion_r4323752438
##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/basic-element/sql-data-types/conversion/file-conversion.md:
##########
@@ -0,0 +1,180 @@
+---
+{
+ "title": "转换为/从 FILE",
+ "language": "zh-CN",
+ "description": "FILE 与 STRUCT、JSON、VARIANT 的显式双向转换及 NULL 处理规则。"
+}
+---
+
+# 转换为/从 FILE
+
+FILE 支持与 STRUCT、JSON、VARIANT 显式双向转换。**FILE 与这些类型之间不支持隐式转换,须使用 CAST。**
转换本身不访问远端存储,字段定义及取值约束见 [FILE](../semi-structured/FILE.md)。
+
+## 转换为 FILE
+
+### FROM STRUCT
+
+源 STRUCT 须包含完整六字段,按名称匹配,不区分大小写,字段顺序可不同。offset 和 size 须为 BIGINT 或 NULL,inline
须为 VARBINARY 或 NULL,文本字段须为 CHAR/VARCHAR/STRING 或 NULL。未知、缺失、重复或类型不兼容的字段会被拒绝。
+
+```sql
+SELECT CAST(NAMED_STRUCT(
+ 'uri', 's3://linrrzqqq/doris-file-type-test/my-github-avatar.jpg',
'offset', NULL, 'size', CAST(3 AS BIGINT),
+ 'content_type', NULL, 'checksum', NULL, 'inline', X'616263'
+) AS FILE) AS f;
+```
+```text
++-----------------------------------------------------------------------------------------------------------+
+| f
|
++-----------------------------------------------------------------------------------------------------------+
+|
{"uri":"s3://linrrzqqq/doris-file-type-test/my-github-avatar.jpg","offset":null,"size":3,"content_type":null,"checksum":null,"inline":"YWJj"}
|
++-----------------------------------------------------------------------------------------------------------+
+```
+
+### FROM JSON
+
+JSON 对象须恰好包含 uri、offset、size、content_type、checksum、inline 六个小写 key。offset 和
size 接受 BIGINT 范围的 JSON 整数或 null;inline 接受标准、带 padding 的 Base64 字符串或
null,空字符串表示空字节序列。
+
+```sql
+SELECT CAST(JSON_PARSE(
+
'{"uri":"s3://linrrzqqq/doris-file-type-test/my-github-avatar.jpg","offset":null,"size":3,"content_type":null,"checksum":null,"inline":"YWJj"}'
+) AS FILE) AS f;
+```
+```text
++-----------------------------------------------------------------------------------------------------------+
+| f
|
++-----------------------------------------------------------------------------------------------------------+
+|
{"uri":"s3://linrrzqqq/doris-file-type-test/my-github-avatar.jpg","offset":null,"size":3,"content_type":null,"checksum":null,"inline":"YWJj"}
|
++-----------------------------------------------------------------------------------------------------------+
+```
+
+### FROM VARIANT
+
+对象形式的 VARIANT 使用与 JSON 相同的字段名、字段类型及 Base64 表示。
+
+```sql
+SELECT CAST(PARSE_TO_VARIANT(
+
'{"uri":"s3://linrrzqqq/doris-file-type-test/my-github-avatar.jpg","offset":null,"size":3,"content_type":null,"checksum":null,"inline":"YWJj"}'
+) AS FILE) AS f;
+```
+```text
++-----------------------------------------------------------------------------------------------------------+
+| f
|
++-----------------------------------------------------------------------------------------------------------+
+|
{"uri":"s3://linrrzqqq/doris-file-type-test/my-github-avatar.jpg","offset":null,"size":3,"content_type":null,"checksum":null,"inline":"YWJj"}
|
++-----------------------------------------------------------------------------------------------------------+
+```
+
+### FROM NULL
+
+SQL NULL 和 JSON null 可显式转换为 NULL FILE。
+
+```sql
+SELECT CAST(NULL AS FILE) AS f;
+```
+```text
++------+
+| f |
++------+
+| NULL |
++------+
+```
+
+## 从 FILE 转换
+
+### TO STRUCT
+
+目标 STRUCT 须包含完整六字段,按名称匹配,不区分大小写。各字段均须允许 NULL:uri、content_type、checksum
使用字符串类型,offset 和 size 使用 BIGINT,inline 使用 VARBINARY。转换保留 inline 原始二进制内容。
+
+```sql
+SELECT CAST(f AS STRUCT<uri:STRING, offset:BIGINT, size:BIGINT,
+ content_type:STRING, checksum:STRING, inline:VARBINARY>) AS s
+FROM (SELECT CAST(NAMED_STRUCT(
+ 'uri', 's3://linrrzqqq/doris-file-type-test/my-github-avatar.jpg',
'offset', NULL, 'size', CAST(3 AS BIGINT),
+ 'content_type', NULL, 'checksum', NULL, 'inline', X'616263'
+) AS FILE) AS f) t;
+```
+```text
++------------------------------------------------------------------------------------------------------------------+
+| s
|
++------------------------------------------------------------------------------------------------------------------+
+| {"uri":"s3://linrrzqqq/doris-file-type-test/my-github-avatar.jpg",
"offset":null, "size":3, "content_type":null, "checksum":null,
"inline":0x616263} |
++------------------------------------------------------------------------------------------------------------------+
+```
+
+### TO JSON
Review Comment:
这些to json 之类的也不支持了
--
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]