Skip to content

Commit

Permalink
Update array.md by adding Array Size part
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Cheng authored Feb 29, 2024
1 parent 9b3a027 commit 7116dd7
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion docs/zh/sql-reference/data-types/array.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
slug: /zh/sql-reference/data-types/array
---
# 阵列(T) {#data-type-array}
# 数组(T) {#data-type-array}

`T` 类型元素组成的数组。

Expand Down Expand Up @@ -66,3 +66,27 @@ SELECT array(1, 'a')
Received exception from server (version 1.1.54388):
Code: 386. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: There is no supertype for types UInt8, String because some of them are String/FixedString and some of them are not.
```

## 数组大小 {#array-size}

可以使用`size0`子列找到数组的大小,而无需读取整个列。对于多维数组,您可以使用`sizeN-1`,其中`N`是所需的维度。

**例子**

SQL查询:

```sql
CREATE TABLE t_arr (`arr` Array(Array(Array(UInt32)))) ENGINE = MergeTree ORDER BY tuple();

INSERT INTO t_arr VALUES ([[[12, 13, 0, 1],[12]]]);

SELECT arr.size0, arr.size1, arr.size2 FROM t_arr;
```

结果:

``` text
┌─arr.size0─┬─arr.size1─┬─arr.size2─┐
│ 1 │ [2] │ [[4,1]] │
└───────────┴───────────┴───────────┘
```

0 comments on commit 7116dd7

Please sign in to comment.