This is an automated email from the ASF dual-hosted git repository.
zclllyybb 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 48e681c794b [Feature](function) Support function ARRAY_CROSS_PRODUCT
(#3891)
48e681c794b is described below
commit 48e681c794bfebd270a3b0bcaf124e1dcc920ba1
Author: linrrarity <[email protected]>
AuthorDate: Wed Jun 3 12:12:25 2026 +0800
[Feature](function) Support function ARRAY_CROSS_PRODUCT (#3891)
## Versions
- [x] dev
- [x] 4.x
- [ ] 3.x
- [ ] 2.1 or older (not covered by version/language sync gate)
## Languages
- [x] Chinese
- [x] English
- [ ] Japanese candidate translation needed
## Docs Checklist
- [ ] Checked by AI
- [ ] Test Cases Built
- [ ] Updated required version and language counterparts, or explained
why not
- [ ] If only one language changed, confirmed whether source/translation
counterparts need sync
---
.../array-functions/array-cross-product.md | 146 ++++++++------------
.../array-functions/array-cross-product.md | 148 ++++++++------------
.../array-functions/array-cross-product.md | 152 ++++++++-------------
.../array-functions/array-cross-product.md | 150 ++++++++------------
4 files changed, 230 insertions(+), 366 deletions(-)
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
index b6640c9492e..78db222384f 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
@@ -1,125 +1,89 @@
---
{
- "title": "CROSS_PRODUCT",
- "language": "en"
+ "title": "ARRAY_CROSS_PRODUCT",
+ "language": "en",
+ "description": "Calculates the cross product of two three-dimensional
numeric arrays."
}
---
## Description
-Computes the cross product of two arrays of size 3.
+Calculates the cross product of two three-dimensional numeric arrays.
+
+For `lhs = [x1, x2, x3]` and `rhs = [y1, y2, y3]`, the result is:
+
+`lhs x rhs = [x2 * y3 - x3 * y2, x3 * y1 - x1 * y3, x1 * y2 - x2 * y1]`
+
+## Alias
+
+- `cross_product`
## Syntax
```sql
-CROSS_PRODUCT(<array1>, <array2>)
+array_cross_product(ARRAY<T> lhs, ARRAY<T> rhs)
```
## 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. Neither the array itself nor any of its
elements can be NULL.|
-| `<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. Neither the array itself nor any of its
elements can be NULL.|
+|---|---|
+| `lhs` | The first three-dimensional numeric array |
+| `rhs` | The second three-dimensional numeric array |
+
+`T` supports `FLOAT`, and integer array element types such as `TINYINT`,
`SMALLINT`, `INT`, `BIGINT`, and `LARGEINT`.
## Return Value
-Returns the cross product of two arrays of size 3.
+Returns `ARRAY<FLOAT>`.
+
+- Returns `NULL` if any input array is `NULL`.
+- Returns an error if any input array contains `NULL` elements.
+- An error is returned if either input array does not contain exactly three
elements.
## Examples
-### normal cases
-simple queries:
```sql
-SELECT CROSS_PRODUCT([1, 2, 3], [2, 3, 4]);
-+-------------------------------------+
-| CROSS_PRODUCT([1, 2, 3], [2, 3, 4]) |
-+-------------------------------------+
-| [-1, 2, -1] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT([1, 2, 3], [0, 0, 0]);
-+-------------------------------------+
-| CROSS_PRODUCT([1, 2, 3], [0, 0, 0]) |
-+-------------------------------------+
-| [0, 0, 0] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT([1, 0, 0], [0, 1, 0]);
-+-------------------------------------+
-| CROSS_PRODUCT([1, 0, 0], [0, 1, 0]) |
-+-------------------------------------+
-| [0, 0, 1] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT([0, 1, 0], [1, 0, 0]);
-+-------------------------------------+
-| CROSS_PRODUCT([0, 1, 0], [1, 0, 0]) |
-+-------------------------------------+
-| [0, 0, -1] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT(NULL, [1, 2, 3]);
-+--------------------------------+
-| CROSS_PRODUCT(NULL, [1, 2, 3]) |
-+--------------------------------+
-| NULL |
-+--------------------------------+
-SELECT CROSS_PRODUCT([1, 2, 3], NULL);
-+--------------------------------+
-| CROSS_PRODUCT([1, 2, 3], NULL) |
-+--------------------------------+
-| NULL |
-+--------------------------------+
+SELECT array_cross_product([2.5, -3.0, 4.25], [-7.5, 0.5, 1.25]);
```
-query with table:
-```sql
-CREATE TABLE array_cross_product_test (
- id INT,
- vec1 ARRAY<DOUBLE>,
- vec2 ARRAY<DOUBLE>
-)
-DUPLICATE KEY(id)
-DISTRIBUTED BY HASH(id) BUCKETS 3
-PROPERTIES (
- "replication_num" = "1"
-);
-INSERT INTO array_cross_product_test VALUES
-(1, [1, 2, 3], [2, 3, 4]),
-(2, [1, 2, 3], [0, 0, 0]),
-(3, [1, 0, 0], [0, 1, 0]),
-(4, [0, 1, 0], [1, 0, 0]),
-(5, NULL, [1, 0, 0]);
-
-SELECT id, CROSS_PRODUCT(vec1, vec2) from array_cross_product_test order by id;
-+------+---------------------------+
-| id | CROSS_PRODUCT(vec1, vec2) |
-+------+---------------------------+
-| 1 | [-1, 2, -1] |
-| 2 | [0, 0, 0] |
-| 3 | [0, 0, 1] |
-| 4 | [0, 0, -1] |
-| 5 | NULL |
-+------+---------------------------+
+
+```text
++--------------------------------------------------------------+
+| array_cross_product([2.5, -3.0, 4.25], [-7.5, 0.5, 1.25]) |
++--------------------------------------------------------------+
+| [-5.875, -35, -21.25] |
++--------------------------------------------------------------+
```
-### abnormal cases
-One of the elements in the argument array is NULL.
```sql
-SELECT CROSS_PRODUCT([1, NULL, 3], [1, 2, 3])
-First argument for function cross_product cannot have null elements
+SELECT array_cross_product(CAST([-128, 0, 127] AS ARRAY<TINYINT>),
+ CAST([3, -5, 7] AS ARRAY<TINYINT>));
```
-```sql
-SELECT CROSS_PRODUCT([1, 2, 3], [NULL, 2, 3]);
-Second argument for function cross_product cannot have null elements
+
+```text
++---------------------------------------------------------------------------------------------------+
+| array_cross_product(CAST([-128, 0, 127] AS ARRAY<TINYINT>), CAST([3, -5, 7]
AS ARRAY<TINYINT>)) |
++---------------------------------------------------------------------------------------------------+
+| [635, 1277, 640]
|
++---------------------------------------------------------------------------------------------------+
```
-The two argument arrays have different lengths.
+
```sql
-SELECT CROSS_PRODUCT([1, 2, 3], [1, 2]);
-function cross_product have different input element sizes of array: 3 and 2
+SELECT array_cross_product(CAST(NULL AS ARRAY<FLOAT>), [4.0, 5.0, 6.0]);
```
-The argument arrays have the same length, but the length is not 3.
-```sql
-SELECT CROSS_PRODUCT([1, 2, 3, 4], [1, 2, 3, 4]);
-function cross_product requires arrays of size 3
+
+```text
++--------------------------------------------------------------------------+
+| array_cross_product(CAST(NULL AS ARRAY<FLOAT>), [4.0, 5.0, 6.0]) |
++--------------------------------------------------------------------------+
+| NULL |
++--------------------------------------------------------------------------+
```
+
```sql
-SELECT CROSS_PRODUCT([1, 2], [3, 4]);
-function cross_product requires arrays of size 3
+SELECT array_cross_product([-11, NULL, 13], [17, -19, 23]);
```
+
+```text
+ERROR 1105 (HY000): errCode = 2, detailMessage = function array_cross_product
cannot have null
+```
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
index 103f8ba09df..0106c344181 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
@@ -1,125 +1,89 @@
---
{
- "title": "CROSS_PRODUCT",
- "language": "zh-CN"
+ "title": "ARRAY_CROSS_PRODUCT",
+ "language": "zh-CN",
+ "description": "计算两个三维数值数组的叉积。"
}
---
## 描述
-计算两个三维向量的叉积
+计算两个三维数值数组的叉积。
+
+对于 `lhs = [x1, x2, x3]` 和 `rhs = [y1, y2, y3]`,返回结果为:
+
+`lhs x rhs = [x2 * y3 - x3 * y2, x3 * y1 - x1 * y3, x1 * y2 - x2 * y1]`
+
+## 别名
+
+- `cross_product`
## 语法
```sql
-CROSS_PRODUCT(<array1>, <array2>)
+array_cross_product(ARRAY<T> lhs, ARRAY<T> rhs)
```
## 参数
| 参数 | 说明 |
-| -- |--|
-| `<array1>` |
第一个向量,输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素数量需与
array2 保持一致,数组本身与数组元素均不允许为NULL|
-| `<array2>` |
第二个向量,输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素数量需与
array1 保持一致,数组本身与数组元素均不允许为NULL|
+|---|---|
+| `lhs` | 第一个三维数值数组 |
+| `rhs` | 第二个三维数值数组 |
+
+`T` 支持 `FLOAT`,以及元素类型为 `TINYINT`、`SMALLINT`、`INT`、`BIGINT`、`LARGEINT` 的整数数组。
## 返回值
-返回两个三维向量的叉积。
+返回 `ARRAY<FLOAT>`。
+
+- 如果任一输入数组为 `NULL`,返回 `NULL`。
+- 如果输入数组内部存在 `NULL` 元素,返回错误。
+- 如果任一输入数组的元素个数不是 3,返回错误。
-## 举例
+## 示例
-### 正常情况
-简单查询
```sql
-SELECT CROSS_PRODUCT([1, 2, 3], [2, 3, 4]);
-+-------------------------------------+
-| CROSS_PRODUCT([1, 2, 3], [2, 3, 4]) |
-+-------------------------------------+
-| [-1, 2, -1] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT([1, 2, 3], [0, 0, 0]);
-+-------------------------------------+
-| CROSS_PRODUCT([1, 2, 3], [0, 0, 0]) |
-+-------------------------------------+
-| [0, 0, 0] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT([1, 0, 0], [0, 1, 0]);
-+-------------------------------------+
-| CROSS_PRODUCT([1, 0, 0], [0, 1, 0]) |
-+-------------------------------------+
-| [0, 0, 1] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT([0, 1, 0], [1, 0, 0]);
-+-------------------------------------+
-| CROSS_PRODUCT([0, 1, 0], [1, 0, 0]) |
-+-------------------------------------+
-| [0, 0, -1] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT(NULL, [1, 2, 3]);
-+--------------------------------+
-| CROSS_PRODUCT(NULL, [1, 2, 3]) |
-+--------------------------------+
-| NULL |
-+--------------------------------+
-SELECT CROSS_PRODUCT([1, 2, 3], NULL);
-+--------------------------------+
-| CROSS_PRODUCT([1, 2, 3], NULL) |
-+--------------------------------+
-| NULL |
-+--------------------------------+
+SELECT array_cross_product([2.5, -3.0, 4.25], [-7.5, 0.5, 1.25]);
```
-表查询
-```sql
-CREATE TABLE array_cross_product_test (
- id INT,
- vec1 ARRAY<DOUBLE>,
- vec2 ARRAY<DOUBLE>
-)
-DUPLICATE KEY(id)
-DISTRIBUTED BY HASH(id) BUCKETS 3
-PROPERTIES (
- "replication_num" = "1"
-);
-INSERT INTO array_cross_product_test VALUES
-(1, [1, 2, 3], [2, 3, 4]),
-(2, [1, 2, 3], [0, 0, 0]),
-(3, [1, 0, 0], [0, 1, 0]),
-(4, [0, 1, 0], [1, 0, 0]),
-(5, NULL, [1, 0, 0]);
-
-SELECT id, CROSS_PRODUCT(vec1, vec2) from array_cross_product_test order by id;
-+------+---------------------------+
-| id | CROSS_PRODUCT(vec1, vec2) |
-+------+---------------------------+
-| 1 | [-1, 2, -1] |
-| 2 | [0, 0, 0] |
-| 3 | [0, 0, 1] |
-| 4 | [0, 0, -1] |
-| 5 | NULL |
-+------+---------------------------+
+
+```text
++--------------------------------------------------------------+
+| array_cross_product([2.5, -3.0, 4.25], [-7.5, 0.5, 1.25]) |
++--------------------------------------------------------------+
+| [-5.875, -35, -21.25] |
++--------------------------------------------------------------+
```
-### 异常情况
-参数数组中某一元素为NULL
```sql
-SELECT CROSS_PRODUCT([1, NULL, 3], [1, 2, 3])
-First argument for function cross_product cannot have null elements
+SELECT array_cross_product(CAST([-128, 0, 127] AS ARRAY<TINYINT>),
+ CAST([3, -5, 7] AS ARRAY<TINYINT>));
```
-```sql
-SELECT CROSS_PRODUCT([1, 2, 3], [NULL, 2, 3]);
-Second argument for function cross_product cannot have null elements
+
+```text
++---------------------------------------------------------------------------------------------------+
+| array_cross_product(CAST([-128, 0, 127] AS ARRAY<TINYINT>), CAST([3, -5, 7]
AS ARRAY<TINYINT>)) |
++---------------------------------------------------------------------------------------------------+
+| [635, 1277, 640]
|
++---------------------------------------------------------------------------------------------------+
```
-两个参数数组长度不一致
+
```sql
-SELECT CROSS_PRODUCT([1, 2, 3], [1, 2]);
-function cross_product have different input element sizes of array: 3 and 2
+SELECT array_cross_product(CAST(NULL AS ARRAY<FLOAT>), [4.0, 5.0, 6.0]);
```
-参数数组长度不为3
-```sql
-SELECT CROSS_PRODUCT([1, 2, 3, 4], [1, 2, 3, 4]);
-function cross_product requires arrays of size 3
+
+```text
++--------------------------------------------------------------------------+
+| array_cross_product(CAST(NULL AS ARRAY<FLOAT>), [4.0, 5.0, 6.0]) |
++--------------------------------------------------------------------------+
+| NULL |
++--------------------------------------------------------------------------+
```
+
```sql
-SELECT CROSS_PRODUCT([1, 2], [3, 4]);
-function cross_product requires arrays of size 3
+SELECT array_cross_product([-11, NULL, 13], [17, -19, 23]);
+```
+
+```text
+ERROR 1105 (HY000): errCode = 2, detailMessage = function array_cross_product
cannot have null
```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
index 103f8ba09df..066714445e1 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
@@ -1,125 +1,93 @@
---
{
- "title": "CROSS_PRODUCT",
- "language": "zh-CN"
+ "title": "ARRAY_CROSS_PRODUCT",
+ "language": "zh-CN",
+ "description": "计算两个三维数值数组的叉积。"
}
---
## 描述
-计算两个三维向量的叉积
+计算两个三维数值数组的叉积。
+
+对于 `lhs = [x1, x2, x3]` 和 `rhs = [y1, y2, y3]`,返回结果为:
+
+`lhs x rhs = [x2 * y3 - x3 * y2, x3 * y1 - x1 * y3, x1 * y2 - x2 * y1]`
+
+:::note
+Since 4.1.2
+:::
+
+## 别名
+
+- `cross_product`
## 语法
```sql
-CROSS_PRODUCT(<array1>, <array2>)
+array_cross_product(ARRAY<T> lhs, ARRAY<T> rhs)
```
## 参数
| 参数 | 说明 |
-| -- |--|
-| `<array1>` |
第一个向量,输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素数量需与
array2 保持一致,数组本身与数组元素均不允许为NULL|
-| `<array2>` |
第二个向量,输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素数量需与
array1 保持一致,数组本身与数组元素均不允许为NULL|
+|---|---|
+| `lhs` | 第一个三维数值数组 |
+| `rhs` | 第二个三维数值数组 |
+
+`T` 支持 `FLOAT`,以及元素类型为 `TINYINT`、`SMALLINT`、`INT`、`BIGINT`、`LARGEINT` 的整数数组。
## 返回值
-返回两个三维向量的叉积。
+返回 `ARRAY<FLOAT>`。
-## 举例
+- 如果任一输入数组为 `NULL`,返回 `NULL`。
+- 如果输入数组内部存在 `NULL` 元素,返回错误。
+- 如果任一输入数组的元素个数不是 3,返回错误。
+
+## 示例
-### 正常情况
-简单查询
```sql
-SELECT CROSS_PRODUCT([1, 2, 3], [2, 3, 4]);
-+-------------------------------------+
-| CROSS_PRODUCT([1, 2, 3], [2, 3, 4]) |
-+-------------------------------------+
-| [-1, 2, -1] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT([1, 2, 3], [0, 0, 0]);
-+-------------------------------------+
-| CROSS_PRODUCT([1, 2, 3], [0, 0, 0]) |
-+-------------------------------------+
-| [0, 0, 0] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT([1, 0, 0], [0, 1, 0]);
-+-------------------------------------+
-| CROSS_PRODUCT([1, 0, 0], [0, 1, 0]) |
-+-------------------------------------+
-| [0, 0, 1] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT([0, 1, 0], [1, 0, 0]);
-+-------------------------------------+
-| CROSS_PRODUCT([0, 1, 0], [1, 0, 0]) |
-+-------------------------------------+
-| [0, 0, -1] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT(NULL, [1, 2, 3]);
-+--------------------------------+
-| CROSS_PRODUCT(NULL, [1, 2, 3]) |
-+--------------------------------+
-| NULL |
-+--------------------------------+
-SELECT CROSS_PRODUCT([1, 2, 3], NULL);
-+--------------------------------+
-| CROSS_PRODUCT([1, 2, 3], NULL) |
-+--------------------------------+
-| NULL |
-+--------------------------------+
+SELECT array_cross_product([2.5, -3.0, 4.25], [-7.5, 0.5, 1.25]);
```
-表查询
-```sql
-CREATE TABLE array_cross_product_test (
- id INT,
- vec1 ARRAY<DOUBLE>,
- vec2 ARRAY<DOUBLE>
-)
-DUPLICATE KEY(id)
-DISTRIBUTED BY HASH(id) BUCKETS 3
-PROPERTIES (
- "replication_num" = "1"
-);
-INSERT INTO array_cross_product_test VALUES
-(1, [1, 2, 3], [2, 3, 4]),
-(2, [1, 2, 3], [0, 0, 0]),
-(3, [1, 0, 0], [0, 1, 0]),
-(4, [0, 1, 0], [1, 0, 0]),
-(5, NULL, [1, 0, 0]);
-
-SELECT id, CROSS_PRODUCT(vec1, vec2) from array_cross_product_test order by id;
-+------+---------------------------+
-| id | CROSS_PRODUCT(vec1, vec2) |
-+------+---------------------------+
-| 1 | [-1, 2, -1] |
-| 2 | [0, 0, 0] |
-| 3 | [0, 0, 1] |
-| 4 | [0, 0, -1] |
-| 5 | NULL |
-+------+---------------------------+
+
+```text
++--------------------------------------------------------------+
+| array_cross_product([2.5, -3.0, 4.25], [-7.5, 0.5, 1.25]) |
++--------------------------------------------------------------+
+| [-5.875, -35, -21.25] |
++--------------------------------------------------------------+
```
-### 异常情况
-参数数组中某一元素为NULL
```sql
-SELECT CROSS_PRODUCT([1, NULL, 3], [1, 2, 3])
-First argument for function cross_product cannot have null elements
+SELECT array_cross_product(CAST([-128, 0, 127] AS ARRAY<TINYINT>),
+ CAST([3, -5, 7] AS ARRAY<TINYINT>));
```
-```sql
-SELECT CROSS_PRODUCT([1, 2, 3], [NULL, 2, 3]);
-Second argument for function cross_product cannot have null elements
+
+```text
++---------------------------------------------------------------------------------------------------+
+| array_cross_product(CAST([-128, 0, 127] AS ARRAY<TINYINT>), CAST([3, -5, 7]
AS ARRAY<TINYINT>)) |
++---------------------------------------------------------------------------------------------------+
+| [635, 1277, 640]
|
++---------------------------------------------------------------------------------------------------+
```
-两个参数数组长度不一致
+
```sql
-SELECT CROSS_PRODUCT([1, 2, 3], [1, 2]);
-function cross_product have different input element sizes of array: 3 and 2
+SELECT array_cross_product(CAST(NULL AS ARRAY<FLOAT>), [4.0, 5.0, 6.0]);
```
-参数数组长度不为3
-```sql
-SELECT CROSS_PRODUCT([1, 2, 3, 4], [1, 2, 3, 4]);
-function cross_product requires arrays of size 3
+
+```text
++--------------------------------------------------------------------------+
+| array_cross_product(CAST(NULL AS ARRAY<FLOAT>), [4.0, 5.0, 6.0]) |
++--------------------------------------------------------------------------+
+| NULL |
++--------------------------------------------------------------------------+
```
+
```sql
-SELECT CROSS_PRODUCT([1, 2], [3, 4]);
-function cross_product requires arrays of size 3
+SELECT array_cross_product([-11, NULL, 13], [17, -19, 23]);
```
+
+```text
+ERROR 1105 (HY000): errCode = 2, detailMessage = function array_cross_product
cannot have null
+```
\ No newline at end of file
diff --git
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
index b6640c9492e..8db6486440f 100644
---
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
@@ -1,125 +1,93 @@
---
{
- "title": "CROSS_PRODUCT",
- "language": "en"
+ "title": "ARRAY_CROSS_PRODUCT",
+ "language": "en",
+ "description": "Calculates the cross product of two three-dimensional
numeric arrays."
}
---
## Description
-Computes the cross product of two arrays of size 3.
+Calculates the cross product of two three-dimensional numeric arrays.
+
+For `lhs = [x1, x2, x3]` and `rhs = [y1, y2, y3]`, the result is:
+
+`lhs x rhs = [x2 * y3 - x3 * y2, x3 * y1 - x1 * y3, x1 * y2 - x2 * y1]`
+
+:::note
+Since 4.1.2
+:::
+
+## Alias
+
+- `cross_product`
## Syntax
```sql
-CROSS_PRODUCT(<array1>, <array2>)
+array_cross_product(ARRAY<T> lhs, ARRAY<T> rhs)
```
## 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. Neither the array itself nor any of its
elements can be NULL.|
-| `<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. Neither the array itself nor any of its
elements can be NULL.|
+|---|---|
+| `lhs` | The first three-dimensional numeric array |
+| `rhs` | The second three-dimensional numeric array |
+
+`T` supports `FLOAT`, and integer array element types such as `TINYINT`,
`SMALLINT`, `INT`, `BIGINT`, and `LARGEINT`.
## Return Value
-Returns the cross product of two arrays of size 3.
+Returns `ARRAY<FLOAT>`.
+
+- Returns `NULL` if any input array is `NULL`.
+- Returns an error if any input array contains `NULL` elements.
+- An error is returned if either input array does not contain exactly three
elements.
## Examples
-### normal cases
-simple queries:
```sql
-SELECT CROSS_PRODUCT([1, 2, 3], [2, 3, 4]);
-+-------------------------------------+
-| CROSS_PRODUCT([1, 2, 3], [2, 3, 4]) |
-+-------------------------------------+
-| [-1, 2, -1] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT([1, 2, 3], [0, 0, 0]);
-+-------------------------------------+
-| CROSS_PRODUCT([1, 2, 3], [0, 0, 0]) |
-+-------------------------------------+
-| [0, 0, 0] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT([1, 0, 0], [0, 1, 0]);
-+-------------------------------------+
-| CROSS_PRODUCT([1, 0, 0], [0, 1, 0]) |
-+-------------------------------------+
-| [0, 0, 1] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT([0, 1, 0], [1, 0, 0]);
-+-------------------------------------+
-| CROSS_PRODUCT([0, 1, 0], [1, 0, 0]) |
-+-------------------------------------+
-| [0, 0, -1] |
-+-------------------------------------+
-SELECT CROSS_PRODUCT(NULL, [1, 2, 3]);
-+--------------------------------+
-| CROSS_PRODUCT(NULL, [1, 2, 3]) |
-+--------------------------------+
-| NULL |
-+--------------------------------+
-SELECT CROSS_PRODUCT([1, 2, 3], NULL);
-+--------------------------------+
-| CROSS_PRODUCT([1, 2, 3], NULL) |
-+--------------------------------+
-| NULL |
-+--------------------------------+
+SELECT array_cross_product([2.5, -3.0, 4.25], [-7.5, 0.5, 1.25]);
```
-query with table:
-```sql
-CREATE TABLE array_cross_product_test (
- id INT,
- vec1 ARRAY<DOUBLE>,
- vec2 ARRAY<DOUBLE>
-)
-DUPLICATE KEY(id)
-DISTRIBUTED BY HASH(id) BUCKETS 3
-PROPERTIES (
- "replication_num" = "1"
-);
-INSERT INTO array_cross_product_test VALUES
-(1, [1, 2, 3], [2, 3, 4]),
-(2, [1, 2, 3], [0, 0, 0]),
-(3, [1, 0, 0], [0, 1, 0]),
-(4, [0, 1, 0], [1, 0, 0]),
-(5, NULL, [1, 0, 0]);
-
-SELECT id, CROSS_PRODUCT(vec1, vec2) from array_cross_product_test order by id;
-+------+---------------------------+
-| id | CROSS_PRODUCT(vec1, vec2) |
-+------+---------------------------+
-| 1 | [-1, 2, -1] |
-| 2 | [0, 0, 0] |
-| 3 | [0, 0, 1] |
-| 4 | [0, 0, -1] |
-| 5 | NULL |
-+------+---------------------------+
+
+```text
++--------------------------------------------------------------+
+| array_cross_product([2.5, -3.0, 4.25], [-7.5, 0.5, 1.25]) |
++--------------------------------------------------------------+
+| [-5.875, -35, -21.25] |
++--------------------------------------------------------------+
```
-### abnormal cases
-One of the elements in the argument array is NULL.
```sql
-SELECT CROSS_PRODUCT([1, NULL, 3], [1, 2, 3])
-First argument for function cross_product cannot have null elements
+SELECT array_cross_product(CAST([-128, 0, 127] AS ARRAY<TINYINT>),
+ CAST([3, -5, 7] AS ARRAY<TINYINT>));
```
-```sql
-SELECT CROSS_PRODUCT([1, 2, 3], [NULL, 2, 3]);
-Second argument for function cross_product cannot have null elements
+
+```text
++---------------------------------------------------------------------------------------------------+
+| array_cross_product(CAST([-128, 0, 127] AS ARRAY<TINYINT>), CAST([3, -5, 7]
AS ARRAY<TINYINT>)) |
++---------------------------------------------------------------------------------------------------+
+| [635, 1277, 640]
|
++---------------------------------------------------------------------------------------------------+
```
-The two argument arrays have different lengths.
+
```sql
-SELECT CROSS_PRODUCT([1, 2, 3], [1, 2]);
-function cross_product have different input element sizes of array: 3 and 2
+SELECT array_cross_product(CAST(NULL AS ARRAY<FLOAT>), [4.0, 5.0, 6.0]);
```
-The argument arrays have the same length, but the length is not 3.
-```sql
-SELECT CROSS_PRODUCT([1, 2, 3, 4], [1, 2, 3, 4]);
-function cross_product requires arrays of size 3
+
+```text
++--------------------------------------------------------------------------+
+| array_cross_product(CAST(NULL AS ARRAY<FLOAT>), [4.0, 5.0, 6.0]) |
++--------------------------------------------------------------------------+
+| NULL |
++--------------------------------------------------------------------------+
```
+
```sql
-SELECT CROSS_PRODUCT([1, 2], [3, 4]);
-function cross_product requires arrays of size 3
+SELECT array_cross_product([-11, NULL, 13], [17, -19, 23]);
+```
+
+```text
+ERROR 1105 (HY000): errCode = 2, detailMessage = function array_cross_product
cannot have null
```
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]