Skip to content

Commit

Permalink
add array flatten (#1951)
Browse files Browse the repository at this point in the history
## Versions 

- [X] dev
- [ ] 3.0
- [ ] 2.1
- [ ] 2.0

## Languages

- [X] Chinese
- [X] English

## Docs Checklist

- [ ] Checked by AI
- [ ] Test Cases Built
  • Loading branch information
BiteTheDDDDt authored Jan 27, 2025
1 parent 733d881 commit 0ef751b
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
{
"title": "ARRAY_FLATTEN",
"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.
-->

## array_flatten

array_flatten

### description

#### Syntax

```sql
ARRAY<T> array_flatten(ARRAY<ARRAY<T>> array1)
```

Flatten a multidimensional array into one dimension.

### example

```sql
mysql> select array_flatten([[1,2,3],[4,5]]);
+--------------------------------+
| array_flatten([[1,2,3],[4,5]]) |
+--------------------------------+
| [1, 2, 3, 4, 5] |
+--------------------------------+
1 row in set (0.01 sec)

mysql> select array_flatten([[[[[[1,2,3,4,5],[6,7],[8,9],[10,11],[12]],[[13]]],[[[14]]]]]]);
+-------------------------------------------------------------------------------+
| array_flatten([[[[[[1,2,3,4,5],[6,7],[8,9],[10,11],[12]],[[13]]],[[[14]]]]]]) |
+-------------------------------------------------------------------------------+
| [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] |
+-------------------------------------------------------------------------------+
1 row in set (0.02 sec)
```

### keywords

ARRAY,ARRAY_FLATTEN
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
{
"title": "ARRAY_FLATTEN",
"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.
-->

## array_flatten

array_flatten

## 描述

## 语法

```sql
ARRAY<T> array_flatten(ARRAY<ARRAY<T>> array1)
```

将多维数组展平成一维。

## 举例

```sql
mysql> select array_flatten([[1,2,3],[4,5]]);
+--------------------------------+
| array_flatten([[1,2,3],[4,5]]) |
+--------------------------------+
| [1, 2, 3, 4, 5] |
+--------------------------------+
1 row in set (0.01 sec)

mysql> select array_flatten([[[[[[1,2,3,4,5],[6,7],[8,9],[10,11],[12]],[[13]]],[[[14]]]]]]);
+-------------------------------------------------------------------------------+
| array_flatten([[[[[[1,2,3,4,5],[6,7],[8,9],[10,11],[12]],[[13]]],[[[14]]]]]]) |
+-------------------------------------------------------------------------------+
| [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] |
+-------------------------------------------------------------------------------+
1 row in set (0.02 sec)
```

### keywords

ARRAY,ARRAY_FLATTEN
1 change: 1 addition & 0 deletions sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,7 @@
"sql-manual/sql-functions/scalar-functions/array-functions/array-first-index",
"sql-manual/sql-functions/scalar-functions/array-functions/array-last-index",
"sql-manual/sql-functions/scalar-functions/array-functions/array-first",
"sql-manual/sql-functions/scalar-functions/array-functions/array-flatten",
"sql-manual/sql-functions/scalar-functions/array-functions/array-last",
"sql-manual/sql-functions/scalar-functions/array-functions/arrays-overlap",
"sql-manual/sql-functions/scalar-functions/array-functions/array-count",
Expand Down

0 comments on commit 0ef751b

Please sign in to comment.