This is an automated email from the ASF dual-hosted git repository.
morningman 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 4fc6ca3843b [Feature](function) Support function cross_product of
DuckDB (#3209)
4fc6ca3843b is described below
commit 4fc6ca3843be13a6df1061dbafc7aa75736aecb6
Author: zy <[email protected]>
AuthorDate: Tue Mar 17 01:45:29 2026 +0800
[Feature](function) Support function cross_product of DuckDB (#3209)
## Versions
- [x] dev
- [x] 4.x
- [ ] 3.x
- [ ] 2.1
## Languages
- [x] Chinese
- [x] English
## Docs Checklist
- [ ] Checked by AI
- [ ] Test Cases Built
---
.../array-functions/array-cross-product.md | 125 ++++++++++++++++++++
.../array-functions/array-cross-product.md | 125 ++++++++++++++++++++
.../array-functions/array-cross-product.md | 126 +++++++++++++++++++++
sidebars.ts | 1 +
.../array-functions/array-cross-product.md | 125 ++++++++++++++++++++
versioned_sidebars/version-4.x-sidebars.json | 1 +
6 files changed, 503 insertions(+)
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
new file mode 100644
index 00000000000..ca12ebda714
--- /dev/null
+++
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
@@ -0,0 +1,125 @@
+---
+{
+ "title": "CROSS_PRODUCT",
+ "language": "en"
+}
+---
+
+## Description
+
+Computes the cross product of two arrays of size 3.
+
+## Syntax
+
+```sql
+CROSS_PRODUCT(<array1>, <array2>)
+```
+
+## 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.|
+| `<array1>` | 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.|
+
+## Return Value
+
+Returns the cross product of two arrays of size 3.
+
+## 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 |
++--------------------------------+
+```
+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 |
++------+---------------------------+
+```
+
+### 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
+```
+```sql
+SELECT CROSS_PRODUCT([1, 2, 3], [NULL, 2, 3]);
+Second argument for function cross_product cannot have null elements
+```
+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
+```
+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
+```
+```sql
+SELECT CROSS_PRODUCT([1, 2], [3, 4]);
+function cross_product requires arrays of size 3
+```
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
new file mode 100644
index 00000000000..103f8ba09df
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
@@ -0,0 +1,125 @@
+---
+{
+ "title": "CROSS_PRODUCT",
+ "language": "zh-CN"
+}
+---
+
+## 描述
+
+计算两个三维向量的叉积
+
+## 语法
+
+```sql
+CROSS_PRODUCT(<array1>, <array2>)
+```
+
+## 参数
+
+| 参数 | 说明 |
+| -- |--|
+| `<array1>` |
第一个向量,输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素数量需与
array2 保持一致,数组本身与数组元素均不允许为NULL|
+| `<array2>` |
第二个向量,输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素数量需与
array1 保持一致,数组本身与数组元素均不允许为NULL|
+
+## 返回值
+
+返回两个三维向量的叉积。
+
+## 举例
+
+### 正常情况
+简单查询
+```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 |
++--------------------------------+
+```
+表查询
+```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 |
++------+---------------------------+
+```
+
+### 异常情况
+参数数组中某一元素为NULL
+```sql
+SELECT CROSS_PRODUCT([1, NULL, 3], [1, 2, 3])
+First argument for function cross_product cannot have null elements
+```
+```sql
+SELECT CROSS_PRODUCT([1, 2, 3], [NULL, 2, 3]);
+Second argument for function cross_product cannot have null elements
+```
+两个参数数组长度不一致
+```sql
+SELECT CROSS_PRODUCT([1, 2, 3], [1, 2]);
+function cross_product have different input element sizes of array: 3 and 2
+```
+参数数组长度不为3
+```sql
+SELECT CROSS_PRODUCT([1, 2, 3, 4], [1, 2, 3, 4]);
+function cross_product requires arrays of size 3
+```
+```sql
+SELECT CROSS_PRODUCT([1, 2], [3, 4]);
+function cross_product requires arrays of size 3
+```
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
new file mode 100644
index 00000000000..5ae830bddd7
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
@@ -0,0 +1,126 @@
+---
+{
+ "title": "CROSS_PRODUCT",
+ "language": "zh-CN"
+}
+---
+
+## 描述
+
+计算两个三维向量的叉积
+
+## 语法
+
+```sql
+CROSS_PRODUCT(<array1>, <array2>)
+```
+
+## 参数
+
+| 参数 | 说明 |
+| -- |--|
+| `<array1>` |
第一个向量,输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素数量需与
array2 保持一致,数组本身与数组元素均不允许为NULL|
+| `<array2>` |
第二个向量,输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素数量需与
array1 保持一致,数组本身与数组元素均不允许为NULL|
+
+## 返回值
+
+返回两个三维向量的叉积。
+
+## 举例
+
+### 正常情况
+简单查询
+```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 |
++--------------------------------+
+```
+表查询
+```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 |
++------+---------------------------+
+```
+
+### 异常情况
+参数数组中某一元素为NULL
+```sql
+SELECT CROSS_PRODUCT([1, NULL, 3], [1, 2, 3])
+First argument for function cross_product cannot have null elements
+```
+```sql
+SELECT CROSS_PRODUCT([1, 2, 3], [NULL, 2, 3]);
+Second argument for function cross_product cannot have null elements
+```
+两个参数数组长度不一致
+```sql
+SELECT CROSS_PRODUCT([1, 2, 3], [1, 2]);
+function cross_product have different input element sizes of array: 3 and 2
+```
+参数数组长度不为3
+```sql
+SELECT CROSS_PRODUCT([1, 2, 3, 4], [1, 2, 3, 4]);
+function cross_product requires arrays of size 3
+```
+```sql
+SELECT CROSS_PRODUCT([1, 2], [3, 4]);
+function cross_product requires arrays of size 3
+```
+
diff --git a/sidebars.ts b/sidebars.ts
index 5bd037d54e9..d450b43a68b 100644
--- a/sidebars.ts
+++ b/sidebars.ts
@@ -1637,6 +1637,7 @@ const sidebars: SidebarsConfig = {
'sql-manual/sql-functions/scalar-functions/array-functions/array-contains',
'sql-manual/sql-functions/scalar-functions/array-functions/array-contains_all',
'sql-manual/sql-functions/scalar-functions/array-functions/array-count',
+
'sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product',
'sql-manual/sql-functions/scalar-functions/array-functions/array-cum-sum',
'sql-manual/sql-functions/scalar-functions/array-functions/array-difference',
'sql-manual/sql-functions/scalar-functions/array-functions/array-distinct',
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
new file mode 100644
index 00000000000..f90a026c066
--- /dev/null
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product.md
@@ -0,0 +1,125 @@
+---
+{
+ "title": "CROSS_PRODUCT",
+ "language": "en"
+}
+---
+
+## Description
+
+Computes the cross product of two arrays of size 3.
+
+## Syntax
+
+```sql
+CROSS_PRODUCT(<array1>, <array2>)
+```
+
+## 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.|
+| `<array1>` | 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.|
+
+## Return Value
+
+Returns the cross product of two arrays of size 3.
+
+## 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 |
++--------------------------------+
+```
+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 |
++------+---------------------------+
+```
+
+### 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
+```
+```sql
+SELECT CROSS_PRODUCT([1, 2, 3], [NULL, 2, 3]);
+Second argument for function cross_product cannot have null elements
+```
+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
+```
+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
+```
+```sql
+SELECT CROSS_PRODUCT([1, 2], [3, 4]);
+function cross_product requires arrays of size 3
+```
\ No newline at end of file
diff --git a/versioned_sidebars/version-4.x-sidebars.json
b/versioned_sidebars/version-4.x-sidebars.json
index 4dd6cf87276..cb4bd320d6c 100644
--- a/versioned_sidebars/version-4.x-sidebars.json
+++ b/versioned_sidebars/version-4.x-sidebars.json
@@ -1651,6 +1651,7 @@
"sql-manual/sql-functions/scalar-functions/array-functions/array-contains",
"sql-manual/sql-functions/scalar-functions/array-functions/array-contains_all",
"sql-manual/sql-functions/scalar-functions/array-functions/array-count",
+
"sql-manual/sql-functions/scalar-functions/array-functions/array-cross-product",
"sql-manual/sql-functions/scalar-functions/array-functions/array-cum-sum",
"sql-manual/sql-functions/scalar-functions/array-functions/array-difference",
"sql-manual/sql-functions/scalar-functions/array-functions/array-distinct",
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]