Skip to content

Commit

Permalink
add doc of subvector() (#1007)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangj1211 authored Apr 26, 2024
1 parent 0b936c7 commit 0179266
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SUBVECTOR()

## 函数说明

`SUBVECTOR()` 函数用于从向量中提取子向量。

## 函数语法

```
> SUBVECTOR(vec, pos, len)
```

## 参数释义

| 参数 | 说明 |
| ---- | ---- |
|vec | 必需参数。从中提取子向量的源向量|
|pos | 必需参数。开始提取的位置。向量中的第一个位置是 1,如果 pos 为正,则函数从向量的开头提取。如果 pos 为负,则提取是从向量的末尾开始。|
|len | 可选参数。要提取的维度数。默认从位置 pos 开始到向量末尾的子向量。如果 len 小于 1,则返回空向量。 |

## 示例

```sql
mysql> SELECT SUBVECTOR("[1,2,3]", 2);
+-----------------------+
| subvector([1,2,3], 2) |
+-----------------------+
| [2, 3] |
+-----------------------+
1 row in set (0.01 sec)

mysql> SELECT SUBVECTOR("[1,2,3]",-1,1);
+---------------------------+
| subvector([1,2,3], -1, 1) |
+---------------------------+
| [3] |
+---------------------------+
1 row in set (0.00 sec)

mysql> SELECT SUBVECTOR("[1,2,3]",-1,0);
+---------------------------+
| subvector([1,2,3], -1, 0) |
+---------------------------+
| [] |
+---------------------------+
1 row in set (0.00 sec)
```
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,11 @@
| [ABS()](./Vector/misc.md) | 用于计算向量的绝对值|
| [CAST()](./Vector/misc.md) | 用于显式将一个向量从一个向量类型转换为另一个向量类型|
| [SUMMATION()](./Vector/misc.md) | 返回向量中所有元素的总和|
| [INNER_PRODUCT()](./Vector/inner_product.md) | 用于计算两个向量之间的内积/点积|
| [COSINE_SIMILARITY()](./Vector/cosine_similarity.md) | 衡量了两个向量之间夹角的余弦值,通过它们在多维空间中的接近程度来表示它们的相似性|
| [INNER_PRODUCT()](./Vector/inner_product.md) | 用于计算两个向量之间的内积/点积|
| [L1_NORM()](./Vector/l1_norm.md) | 用于计算 l1/曼哈顿/TaxiCab 范数|
| [L2_NORM()](./Vector/l2_norm.md) | 用于计算 l2/欧几里得范数|
| [SUBVECTOR()](./Vector/subvector.md) | 用于从向量中提取子向量|
| [VECTOR_DIMS()](./Vector/vector_dims.md) | 用于确定向量的维度|

## 表函数
Expand Down
11 changes: 6 additions & 5 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -559,11 +559,12 @@ nav:
- 向量类:
- 基本操作符: MatrixOne/Reference/Functions-and-Operators/Vector/arithmetic.md
- 数学计算: MatrixOne/Reference/Functions-and-Operators/Vector/misc.md
- 内积计算: MatrixOne/Reference/Functions-and-Operators/Vector/inner_product.md
- 余弦相似度计算: MatrixOne/Reference/Functions-and-Operators/Vector/cosine_similarity.md
- L1 范数函数: MatrixOne/Reference/Functions-and-Operators/Vector/l1_norm.md
- L2 范数函数: MatrixOne/Reference/Functions-and-Operators/Vector/l2_norm.md
- 维度函数: MatrixOne/Reference/Functions-and-Operators/Vector/vector_dims.md
- COSINE_SIMILARITY(): MatrixOne/Reference/Functions-and-Operators/Vector/cosine_similarity.md
- INNER_PRODUCT(): MatrixOne/Reference/Functions-and-Operators/Vector/inner_product.md
- L1_NORM(): MatrixOne/Reference/Functions-and-Operators/Vector/l1_norm.md
- L2_NORM(): MatrixOne/Reference/Functions-and-Operators/Vector/l2_norm.md
- SUBVECTOR(): MatrixOne/Reference/Functions-and-Operators/Vector/subvector.md
- VECTOR_DIMS(): MatrixOne/Reference/Functions-and-Operators/Vector/vector_dims.md
- 表函数:
- UNNEST(): MatrixOne/Reference/Functions-and-Operators/Table/unnest.md
- 窗口函数:
Expand Down

0 comments on commit 0179266

Please sign in to comment.