This is an automated email from the ASF dual-hosted git repository.

HappenLee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git


The following commit(s) were added to refs/heads/master by this push:
     new 1635355180e [doc](function) Document map support for inner_product 
(#4113)
1635355180e is described below

commit 1635355180e23d5a8a95e9c0abb166548b31fd07
Author: Pxl <[email protected]>
AuthorDate: Sun Sep 6 02:16:29 2026 +0800

    [doc](function) Document map support for inner_product (#4113)
---
 .../distance-functions/inner-product.md            | 51 +++++++++++++++++----
 .../distance-functions/inner-product.md            | 53 ++++++++++++++++++----
 2 files changed, 87 insertions(+), 17 deletions(-)

diff --git 
a/docs/sql-manual/sql-functions/ai-functions/distance-functions/inner-product.md
 
b/docs/sql-manual/sql-functions/ai-functions/distance-functions/inner-product.md
index c64ca9ea074..2d5828cfbf5 100644
--- 
a/docs/sql-manual/sql-functions/ai-functions/distance-functions/inner-product.md
+++ 
b/docs/sql-manual/sql-functions/ai-functions/distance-functions/inner-product.md
@@ -2,34 +2,39 @@
 {
     "title": "INNER_PRODUCT",
     "language": "en",
-    "description": "Computes the scalar product of two vectors of the same 
size"
+    "description": "Computes the scalar product of two dense or sparse vectors"
 }
 ---
 
 ## Description
 
-Computes the scalar product of two vectors of the same size
+Computes the scalar product of two dense vectors represented by arrays, or two 
sparse vectors represented by maps. For sparse vectors, each map key identifies 
a dimension and its value is the coordinate. Only dimensions present in both 
maps contribute to the result.
 
 ## Syntax
 
 ```sql
 INNER_PRODUCT(<array1>, <array2>)
+INNER_PRODUCT(<map1>, <map2>)
 ```
 
 ## Parameters
 
 | Parameter | Description |
-| -- |--|
-| `<array1>` | The first vector, the subtype of the input array supports: 
TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, the number of elements 
must be consistent with array2 |
-| `<array2>` | The second vector, the subtype of the input array supports: 
TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, the number of elements 
must be consistent with array1 |
+|---|---|
+| `<array1>` | The first dense vector. Supported element types are TINYINT, 
SMALLINT, INT, BIGINT, LARGEINT, FLOAT, and DOUBLE. The number of elements must 
equal that of `<array2>`. |
+| `<array2>` | The second dense vector. Supported element types are TINYINT, 
SMALLINT, INT, BIGINT, LARGEINT, FLOAT, and DOUBLE. The number of elements must 
equal that of `<array1>`. |
+| `<map1>` | The first sparse vector. Its type must be `MAP<K, FLOAT>`, where 
`K` is an integer type (TINYINT, SMALLINT, INT, BIGINT, or LARGEINT) or a 
string type (CHAR, VARCHAR, or STRING). Its key type must be from the same type 
family as that of `<map2>`. |
+| `<map2>` | The second sparse vector. It has the same type constraints as 
`<map1>`. The two maps can contain different numbers of entries. |
 
 ## Return Value
 
-Returns the scalar product of two vectors of the same size. The return type is 
`FLOAT`.
+Returns the scalar product as a `FLOAT`.
 
-If either input array is `NULL`, or contains a `NULL` element, the function 
returns an error.
+For array inputs, corresponding elements are multiplied and summed. If either 
array is `NULL`, contains a `NULL` element, or the arrays have different 
lengths, the function returns an error.
 
-## Examples
+For map inputs, values with the same key are multiplied and summed. A key that 
occurs in only one map has no effect, which is equivalent to treating the 
missing coordinate as zero. `NULL` keys match other `NULL` keys. If a key 
occurs more than once, its last value is used. If either map is `NULL`, or the 
value retained for any key is `NULL`, the function returns an error.
+
+## Example
 
 ```sql
 SELECT INNER_PRODUCT([1, 2], [2, 3]),INNER_PRODUCT([3, 6], [4, 7]);
@@ -43,6 +48,23 @@ SELECT INNER_PRODUCT([1, 2], [2, 3]),INNER_PRODUCT([3, 6], 
[4, 7]);
 +-------------------------------+-------------------------------+
 ```
 
+The following example computes the inner product of two sparse vectors. Only 
keys `a` and `b` occur in both maps, so the result is `2 * 5 + 3 * 4 = 22`:
+
+```sql
+SELECT INNER_PRODUCT(
+    MAP('a', CAST(2 AS FLOAT), 'b', CAST(3 AS FLOAT)),
+    MAP('b', CAST(4 AS FLOAT), 'c', CAST(100 AS FLOAT), 'a', CAST(5 AS FLOAT))
+) AS result;
+```
+
+```text
++--------+
+| result |
++--------+
+|     22 |
++--------+
+```
+
 If an input array is `NULL`, the function returns an error:
 
 ```sql
@@ -62,3 +84,16 @@ SELECT INNER_PRODUCT([1, NULL], [1, 2]);
 ```text
 ERROR 1105 (HY000): errCode = 2, detailMessage = 
(127.0.0.1)[INVALID_ARGUMENT]First argument for function inner_product cannot 
have null
 ```
+
+If a map value is `NULL`, the function returns an error:
+
+```sql
+SELECT INNER_PRODUCT(
+    MAP(1, CAST(NULL AS FLOAT)),
+    MAP(1, CAST(2 AS FLOAT))
+);
+```
+
+```text
+ERROR 1105 (HY000): errCode = 2, detailMessage = 
(127.0.0.1)[INVALID_ARGUMENT]First argument for function inner_product cannot 
have null
+```
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/ai-functions/distance-functions/inner-product.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/ai-functions/distance-functions/inner-product.md
index c0defe3deeb..b70efea70b3 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/ai-functions/distance-functions/inner-product.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/ai-functions/distance-functions/inner-product.md
@@ -2,34 +2,39 @@
 {
     "title": "INNER_PRODUCT",
     "language": "zh-CN",
-    "description": "计算两个大小相同的向量的标量积"
+    "description": "计算两个稠密向量或稀疏向量的标量积"
 }
 ---
 
 ## 描述
 
-计算两个大小相同的向量的标量积
+计算两个由数组表示的稠密向量,或两个由 Map 表示的稀疏向量的标量积。对于稀疏向量,每个 Map 的 key 表示一个维度,value 
表示该维度的坐标值。只有同时出现在两个 Map 中的维度才参与计算。
 
 ## 语法
 
 ```sql
 INNER_PRODUCT(<array1>, <array2>)
+INNER_PRODUCT(<map1>, <map2>)
 ```
 
 ## 参数
 
-| 参数 | 说明 |
-| -- |--|
-| `<array1>` | 
第一个向量,输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素数量需与 
array2 保持一致 |
-| `<array2>` | 
第二个向量,输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素数量需与 
array1 保持一致 |
+| 参数 | 描述 |
+|---|---|
+| `<array1>` | 第一个稠密向量。数组元素支持 TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT 和 
DOUBLE 类型,元素数量必须与 `<array2>` 相同。 |
+| `<array2>` | 第二个稠密向量。数组元素支持 TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT 和 
DOUBLE 类型,元素数量必须与 `<array1>` 相同。 |
+| `<map1>` | 第一个稀疏向量。类型必须为 `MAP<K, FLOAT>`,其中 `K` 
可以是整数类型(TINYINT、SMALLINT、INT、BIGINT 或 LARGEINT)或字符串类型(CHAR、VARCHAR 或 STRING)。其 
key 类型必须与 `<map2>` 的 key 类型属于同一类型族。 |
+| `<map2>` | 第二个稀疏向量,类型约束与 `<map1>` 相同。两个 Map 的元素数量可以不同。 |
 
 ## 返回值
 
-返回两个大小相同的向量的标量积,返回类型为 `FLOAT`。
+返回标量积,返回类型为 `FLOAT`。
 
-如果任一输入数组为 `NULL`,或包含 `NULL` 元素,函数会报错。
+对于数组输入,将相同位置的元素相乘后求和。如果任一数组为 `NULL`、包含 `NULL` 元素,或两个数组的长度不同,函数会报错。
 
-## 举例
+对于 Map 输入,将相同 key 对应的 value 相乘后求和。只出现在一个 Map 中的 key 不影响结果,相当于缺失维度的坐标值为零。`NULL` 
key 可以与另一个 `NULL` key 匹配。如果一个 key 重复出现,则使用它最后一次出现的 value。如果任一 Map 为 `NULL`,或任一 
key 最终保留的 value 为 `NULL`,函数会报错。
+
+## 示例
 
 ```sql
 SELECT INNER_PRODUCT([1, 2], [2, 3]),INNER_PRODUCT([3, 6], [4, 7]);
@@ -43,6 +48,23 @@ SELECT INNER_PRODUCT([1, 2], [2, 3]),INNER_PRODUCT([3, 6], 
[4, 7]);
 +-------------------------------+-------------------------------+
 ```
 
+以下示例计算两个稀疏向量的内积。只有 key `a` 和 `b` 同时出现在两个 Map 中,因此结果为 `2 * 5 + 3 * 4 = 22`:
+
+```sql
+SELECT INNER_PRODUCT(
+    MAP('a', CAST(2 AS FLOAT), 'b', CAST(3 AS FLOAT)),
+    MAP('b', CAST(4 AS FLOAT), 'c', CAST(100 AS FLOAT), 'a', CAST(5 AS FLOAT))
+) AS result;
+```
+
+```text
++--------+
+| result |
++--------+
+|     22 |
++--------+
+```
+
 如果输入数组为 `NULL`,函数会报错:
 
 ```sql
@@ -62,3 +84,16 @@ SELECT INNER_PRODUCT([1, NULL], [1, 2]);
 ```text
 ERROR 1105 (HY000): errCode = 2, detailMessage = 
(127.0.0.1)[INVALID_ARGUMENT]First argument for function inner_product cannot 
have null
 ```
+
+如果 Map 的 value 为 `NULL`,函数会报错:
+
+```sql
+SELECT INNER_PRODUCT(
+    MAP(1, CAST(NULL AS FLOAT)),
+    MAP(1, CAST(2 AS FLOAT))
+);
+```
+
+```text
+ERROR 1105 (HY000): errCode = 2, detailMessage = 
(127.0.0.1)[INVALID_ARGUMENT]First argument for function inner_product cannot 
have null
+```


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

Reply via email to