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.git


The following commit(s) were added to refs/heads/master by this push:
     new 0d11c4207a [docs](struct-type) add docs for struct and named_struct 
function (#19700)
0d11c4207a is described below

commit 0d11c4207a95350fd529981dc23d38fc3d8cf1a0
Author: xy720 <[email protected]>
AuthorDate: Wed May 17 08:16:33 2023 +0800

    [docs](struct-type) add docs for struct and named_struct function (#19700)
---
 .../sql-functions/struct-functions/named_struct.md | 77 ++++++++++++++++++++
 .../sql-functions/struct-functions/struct.md       | 83 ++++++++++++++++++++++
 docs/sidebars.json                                 |  8 +++
 .../sql-functions/struct-functions/named_struct.md | 77 ++++++++++++++++++++
 .../sql-functions/struct-functions/struct.md       | 83 ++++++++++++++++++++++
 5 files changed, 328 insertions(+)

diff --git 
a/docs/en/docs/sql-manual/sql-functions/struct-functions/named_struct.md 
b/docs/en/docs/sql-manual/sql-functions/struct-functions/named_struct.md
new file mode 100644
index 0000000000..a33497c461
--- /dev/null
+++ b/docs/en/docs/sql-manual/sql-functions/struct-functions/named_struct.md
@@ -0,0 +1,77 @@
+---
+{
+    "title": "named_struct",
+    "language": "en"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## named_struct
+
+<version since="2.0.0">
+
+named_struct
+
+</version>
+
+### description
+
+#### Syntax
+
+`STRUCT<T1, T2, T3, ...> named_struct({VARCHAR, T1}, {VARCHAR, T2}, ...)`
+
+Construct a struct with the given field names and values. 
+
+The number of parameters must be non zero and even. With odd digits being the 
name of the field and could be string literal, with even digits being the value 
of the field and could be column or literal.
+
+### notice
+
+`Only supported in vectorized engine`
+
+### example
+
+```
+mysql> select named_struct('f1', 1, 'f2', 'a', 'f3', "abc");
++-----------------------------------------------+
+| named_struct('f1', 1, 'f2', 'a', 'f3', 'abc') |
++-----------------------------------------------+
+| {1, 'a', 'abc'}                               |
++-----------------------------------------------+
+1 row in set (0.01 sec)
+
+mysql> select named_struct('a', null, 'b', "v");
++-----------------------------------+
+| named_struct('a', NULL, 'b', 'v') |
++-----------------------------------+
+| {NULL, 'v'}                       |
++-----------------------------------+
+1 row in set (0.01 sec)
+
+mysql> select named_struct('f1', k1, 'f2', k2, 'f3', null) from test_tb;
++--------------------------------------------------+
+| named_struct('f1', `k1`, 'f2', `k2`, 'f3', NULL) |
++--------------------------------------------------+
+| {1, 'a', NULL}                                   |
++--------------------------------------------------+
+1 row in set (0.02 sec)
+```
+
+### keywords
+
+NAMED, STRUCT, NAMED_STRUCT
diff --git a/docs/en/docs/sql-manual/sql-functions/struct-functions/struct.md 
b/docs/en/docs/sql-manual/sql-functions/struct-functions/struct.md
new file mode 100644
index 0000000000..4b5691ba1f
--- /dev/null
+++ b/docs/en/docs/sql-manual/sql-functions/struct-functions/struct.md
@@ -0,0 +1,83 @@
+---
+{
+    "title": "struct",
+    "language": "en"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## struct()
+
+<version since="2.0.0">
+
+struct()
+
+</version>
+
+### description
+
+#### Syntax
+
+`STRUCT<T1, T2, T3, ...> struct(T1, T2, T3, ...)`
+
+construct an struct with variadic elements and return it, Tn could be column 
or literal
+
+### notice
+
+`Only supported in vectorized engine`
+
+### example
+
+```
+mysql> select struct(1, 'a', "abc");
++-----------------------+
+| struct(1, 'a', 'abc') |
++-----------------------+
+| {1, 'a', 'abc'}       |
++-----------------------+
+1 row in set (0.03 sec)
+
+mysql> select struct(null, 1, null);
++-----------------------+
+| struct(NULL, 1, NULL) |
++-----------------------+
+| {NULL, 1, NULL}       |
++-----------------------+
+1 row in set (0.02 sec)
+
+mysql> select struct(cast('2023-03-16' as datetime));
++----------------------------------------+
+| struct(CAST('2023-03-16' AS DATETIME)) |
++----------------------------------------+
+| {2023-03-16 00:00:00}                  |
++----------------------------------------+
+1 row in set (0.01 sec)
+
+mysql> select struct(k1, k2, null) from test_tb;
++--------------------------+
+| struct(`k1`, `k2`, NULL) |
++--------------------------+
+| {1, 'a', NULL}           |
++--------------------------+
+1 row in set (0.04 sec)
+```
+
+### keywords
+
+STRUCT,CONSTRUCTOR
\ No newline at end of file
diff --git a/docs/sidebars.json b/docs/sidebars.json
index 5499d59d55..7c5bd1509a 100644
--- a/docs/sidebars.json
+++ b/docs/sidebars.json
@@ -493,6 +493,14 @@
                                 }
                             ]
                         },
+                        {
+                            "type": "category",
+                            "label": "Struct Functions",
+                            "items": [
+                                
"sql-manual/sql-functions/struct-functions/struct",
+                                
"sql-manual/sql-functions/struct-functions/named_struct"
+                            ]
+                        },
                         {
                             "type": "category",
                             "label": "Aggregate Functions",
diff --git 
a/docs/zh-CN/docs/sql-manual/sql-functions/struct-functions/named_struct.md 
b/docs/zh-CN/docs/sql-manual/sql-functions/struct-functions/named_struct.md
new file mode 100644
index 0000000000..b647daa520
--- /dev/null
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/struct-functions/named_struct.md
@@ -0,0 +1,77 @@
+---
+{
+    "title": "named_struct",
+    "language": "zh-CN"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## named_struct
+
+<version since="2.0.0">
+
+named_struct
+
+</version>
+
+### description
+
+#### Syntax
+
+`STRUCT<T1, T2, T3, ...> named_struct({VARCHAR, T1}, {VARCHAR, T2}, ...)`
+
+根据给定的字符串和值构造并返回struct
+
+参数个数必须为非0偶数,奇数位是field的名字,必须为常量字符串,偶数位是field的值,可以是多列或常量
+
+### notice
+
+`仅支持向量化引擎中使用`
+
+### example
+
+```
+mysql> select named_struct('f1', 1, 'f2', 'a', 'f3', "abc");
++-----------------------------------------------+
+| named_struct('f1', 1, 'f2', 'a', 'f3', 'abc') |
++-----------------------------------------------+
+| {1, 'a', 'abc'}                               |
++-----------------------------------------------+
+1 row in set (0.01 sec)
+
+mysql> select named_struct('a', null, 'b', "v");
++-----------------------------------+
+| named_struct('a', NULL, 'b', 'v') |
++-----------------------------------+
+| {NULL, 'v'}                       |
++-----------------------------------+
+1 row in set (0.01 sec)
+
+mysql> select named_struct('f1', k1, 'f2', k2, 'f3', null) from test_tb;
++--------------------------------------------------+
+| named_struct('f1', `k1`, 'f2', `k2`, 'f3', NULL) |
++--------------------------------------------------+
+| {1, 'a', NULL}                                   |
++--------------------------------------------------+
+1 row in set (0.02 sec)
+```
+
+### keywords
+
+NAMED, STRUCT, NAMED_STRUCT
\ No newline at end of file
diff --git 
a/docs/zh-CN/docs/sql-manual/sql-functions/struct-functions/struct.md 
b/docs/zh-CN/docs/sql-manual/sql-functions/struct-functions/struct.md
new file mode 100644
index 0000000000..2c5aaa4c2b
--- /dev/null
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/struct-functions/struct.md
@@ -0,0 +1,83 @@
+---
+{
+    "title": "struct",
+    "language": "zh-CN"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## struct()
+
+<version since="2.0.0">
+
+struct()
+
+</version>
+
+### description
+
+#### Syntax
+
+`STRUCT<T1, T2, T3, ...> struct(T1, T2, T3, ...)`
+
+根据给定的值构造并返回struct,参数可以是多列或常量
+
+### notice
+
+`仅支持向量化引擎中使用`
+
+### example
+
+```
+mysql> select struct(1, 'a', "abc");
++-----------------------+
+| struct(1, 'a', 'abc') |
++-----------------------+
+| {1, 'a', 'abc'}       |
++-----------------------+
+1 row in set (0.03 sec)
+
+mysql> select struct(null, 1, null);
++-----------------------+
+| struct(NULL, 1, NULL) |
++-----------------------+
+| {NULL, 1, NULL}       |
++-----------------------+
+1 row in set (0.02 sec)
+
+mysql> select struct(cast('2023-03-16' as datetime));
++----------------------------------------+
+| struct(CAST('2023-03-16' AS DATETIME)) |
++----------------------------------------+
+| {2023-03-16 00:00:00}                  |
++----------------------------------------+
+1 row in set (0.01 sec)
+
+mysql> select struct(k1, k2, null) from test_tb;
++--------------------------+
+| struct(`k1`, `k2`, NULL) |
++--------------------------+
+| {1, 'a', NULL}           |
++--------------------------+
+1 row in set (0.04 sec)
+```
+
+### keywords
+
+STRUCT, CONSTRUCTOR


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

Reply via email to