Skip to content

[Feature](function) Support function ARRAY_CROSS_PRODUCT#64031

Merged
zclllyybb merged 1 commit into
apache:masterfrom
linrrzqqq:array-cross-product
Jun 3, 2026
Merged

[Feature](function) Support function ARRAY_CROSS_PRODUCT#64031
zclllyybb merged 1 commit into
apache:masterfrom
linrrzqqq:array-cross-product

Conversation

@linrrzqqq
Copy link
Copy Markdown
Collaborator

@linrrzqqq linrrzqqq commented Jun 2, 2026

Issue Number: #48203

Related PR: #59223

doc: apache/doris-website#3891

Problem Summary:

Support function ARRAY_CROSS_PRODUCT

Doris> SELECT CROSS_PRODUCT([1, 2, 3], [2, 3, 4]);
+-------------------------------------+
| CROSS_PRODUCT([1, 2, 3], [2, 3, 4]) |
+-------------------------------------+
| [-1, 2, -1]                         |
+-------------------------------------+
1 row in set (0.021 sec)

Doris> SELECT CROSS_PRODUCT([1, 2, 3], NULL);
+--------------------------------+
| CROSS_PRODUCT([1, 2, 3], NULL) |
+--------------------------------+
| NULL                           |
+--------------------------------+
1 row in set (0.009 sec)

Doris> SELECT CROSS_PRODUCT([1, NULL, 3], [1, 2, 3]);
ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[INVALID_ARGUMENT]function array_cross_product cannot have null
Doris> SELECT CROSS_PRODUCT([1, 2, 3, 4], [1, 2, 3, 4]);
ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[INVALID_ARGUMENT]function array_cross_product requires both input arrays to have exactly 3 elements, got 4 and 4

@hello-stephen
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@linrrzqqq
Copy link
Copy Markdown
Collaborator Author

/review

@linrrzqqq
Copy link
Copy Markdown
Collaborator Author

run buildall

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review summary:

No blocking correctness issues found in this PR. I reviewed the new BE array_cross_product implementation, FE Nereids registration/signature, alias handling for cross_product, FE constant folding implementation, BE unit coverage, and regression coverage. Existing inline review context had no prior comments, and there were no additional user-provided focus points.

Critical checkpoint conclusions:

  • Goal/test coverage: The PR adds array_cross_product/cross_product for 3D arrays and includes BE unit tests plus regression tests covering aliases, constants, table columns, numeric coercion, top-level NULLs, nested NULL errors, and invalid dimensions.
  • Scope/minimality: The change is focused on one scalar function and the required FE/BE registration paths.
  • Concurrency/lifecycle: No new shared state, threads, locks, static initialization dependency, persistence, or lifecycle-sensitive ownership was introduced.
  • Compatibility/protocol: No new thrift protocol, storage format, EditLog, or FE-BE transmitted field changes. The FE signature coerces arguments to ARRAY, matching the BE ColumnFloat32 implementation.
  • Parallel paths: Both FE and BE register the canonical name and alias; FE constant folding and BE execution paths were checked.
  • Null/error handling: Top-level NULL propagation and nested NULL rejection are handled consistently with the declared behavior; Status errors are propagated in BE.
  • Performance/memory: The BE implementation is linear over rows with fixed-size output per non-null row and uses Doris column containers; no obvious hot-path excessive allocation or untracked large allocation issue was found.
  • Observability/config/docs: No new configuration, metrics, or observability requirement is apparent for this scalar function.

User focus response: No additional user-provided review focus was present.

@hello-stephen
Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 95.61% (109/114) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 54.16% (21141/39036)
Line Coverage 37.70% (200833/532756)
Region Coverage 33.83% (158101/467367)
Branch Coverage 34.78% (69015/198409)

@hello-stephen
Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 2.78% (1/36) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 95.61% (109/114) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.91% (28254/38226)
Line Coverage 57.90% (307665/531380)
Region Coverage 54.85% (258761/471788)
Branch Coverage 56.21% (111943/199155)

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 91.67% (33/36) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 29469 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit d25d5e927bc82801a046c3a0c4ccd00040848dff, data reload: false

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17720	4130	4152	4130
q2	q3	10831	1387	810	810
q4	4688	480	352	352
q5	7534	877	582	582
q6	181	169	137	137
q7	764	845	649	649
q8	9361	1704	1580	1580
q9	5733	4533	4511	4511
q10	6782	1819	1539	1539
q11	434	277	248	248
q12	636	435	296	296
q13	18092	3431	2793	2793
q14	261	249	241	241
q15	q16	820	770	722	722
q17	990	921	1066	921
q18	7164	5835	5518	5518
q19	1312	1237	1079	1079
q20	513	422	258	258
q21	6356	2875	2778	2778
q22	452	376	325	325
Total cold run time: 100624 ms
Total hot run time: 29469 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	5251	4839	4932	4839
q2	q3	4892	5401	4665	4665
q4	2103	2188	1370	1370
q5	4799	4910	4695	4695
q6	233	173	131	131
q7	1875	1906	1609	1609
q8	2436	2187	2142	2142
q9	7966	7785	7444	7444
q10	4762	4706	4208	4208
q11	538	385	364	364
q12	725	739	520	520
q13	3059	3518	2775	2775
q14	287	287	257	257
q15	q16	679	710	626	626
q17	1273	1263	1256	1256
q18	7184	6886	6790	6790
q19	1091	1114	1112	1112
q20	2225	2208	1956	1956
q21	5253	4627	4488	4488
q22	532	449	402	402
Total cold run time: 57163 ms
Total hot run time: 51649 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 169519 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit d25d5e927bc82801a046c3a0c4ccd00040848dff, data reload: false

query5	4341	638	501	501
query6	456	203	184	184
query7	4918	554	312	312
query8	372	223	203	203
query9	8765	4032	4030	4030
query10	451	313	271	271
query11	5889	2340	2198	2198
query12	163	113	102	102
query13	1273	625	446	446
query14	6385	5474	5129	5129
query14_1	4347	4359	4362	4359
query15	216	197	173	173
query16	1002	456	417	417
query17	1113	691	562	562
query18	2428	471	344	344
query19	196	181	136	136
query20	118	107	106	106
query21	223	136	117	117
query22	13751	13630	13458	13458
query23	17592	16594	16166	16166
query23_1	16341	16284	16262	16262
query24	7639	1795	1279	1279
query24_1	1281	1309	1327	1309
query25	561	446	390	390
query26	1312	329	166	166
query27	2695	550	365	365
query28	4458	2018	2043	2018
query29	1081	633	509	509
query30	328	255	202	202
query31	1146	1084	957	957
query32	125	64	63	63
query33	529	331	264	264
query34	1179	1131	649	649
query35	785	791	687	687
query36	1397	1396	1254	1254
query37	177	116	96	96
query38	3199	3164	3054	3054
query39	949	919	906	906
query39_1	877	877	895	877
query40	237	127	106	106
query41	73	67	67	67
query42	107	97	95	95
query43	334	328	286	286
query44	
query45	200	189	179	179
query46	1059	1211	770	770
query47	2363	2413	2276	2276
query48	414	381	295	295
query49	647	486	378	378
query50	1054	378	264	264
query51	4323	4258	4228	4228
query52	91	98	80	80
query53	250	273	197	197
query54	290	237	225	225
query55	82	77	72	72
query56	265	240	240	240
query57	1443	1400	1330	1330
query58	259	231	246	231
query59	1589	1687	1489	1489
query60	309	269	252	252
query61	176	180	173	173
query62	702	666	576	576
query63	241	190	232	190
query64	2607	785	619	619
query65	
query66	1802	469	353	353
query67	29808	29714	29594	29594
query68	
query69	446	316	271	271
query70	985	955	974	955
query71	296	222	218	218
query72	3015	2696	2425	2425
query73	857	757	424	424
query74	5163	5008	4800	4800
query75	2662	2587	2256	2256
query76	2332	1143	773	773
query77	357	385	298	298
query78	12409	12521	11827	11827
query79	1331	1086	754	754
query80	605	476	392	392
query81	456	279	247	247
query82	954	158	123	123
query83	355	285	251	251
query84	268	143	110	110
query85	901	526	435	435
query86	368	306	280	280
query87	3391	3343	3228	3228
query88	3634	2729	2708	2708
query89	447	393	331	331
query90	1960	195	182	182
query91	182	165	137	137
query92	65	62	58	58
query93	1472	1415	860	860
query94	557	342	309	309
query95	690	479	357	357
query96	1106	832	356	356
query97	2700	2690	2564	2564
query98	231	207	201	201
query99	1164	1179	1055	1055
Total cold run time: 252647 ms
Total hot run time: 169519 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 95.61% (109/114) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.92% (28255/38226)
Line Coverage 57.91% (307696/531380)
Region Coverage 54.86% (258815/471788)
Branch Coverage 56.22% (111957/199155)

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 91.67% (33/36) 🎉
Increment coverage report
Complete coverage report

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Jun 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

PR approved by anyone and no changes requested.

@zclllyybb zclllyybb merged commit daab2c0 into apache:master Jun 3, 2026
34 of 35 checks passed
linrrzqqq added a commit to linrrzqqq/doris that referenced this pull request Jun 3, 2026
Issue Number: apache#48203

Related PR: apache#59223

doc: apache/doris-website#3891

Problem Summary:

Support function `ARRAY_CROSS_PRODUCT`

```sql
Doris> SELECT CROSS_PRODUCT([1, 2, 3], [2, 3, 4]);
+-------------------------------------+
| CROSS_PRODUCT([1, 2, 3], [2, 3, 4]) |
+-------------------------------------+
| [-1, 2, -1]                         |
+-------------------------------------+
1 row in set (0.021 sec)

Doris> SELECT CROSS_PRODUCT([1, 2, 3], NULL);
+--------------------------------+
| CROSS_PRODUCT([1, 2, 3], NULL) |
+--------------------------------+
| NULL                           |
+--------------------------------+
1 row in set (0.009 sec)

Doris> SELECT CROSS_PRODUCT([1, NULL, 3], [1, 2, 3]);
ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[INVALID_ARGUMENT]function array_cross_product cannot have null
Doris> SELECT CROSS_PRODUCT([1, 2, 3, 4], [1, 2, 3, 4]);
ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[INVALID_ARGUMENT]function array_cross_product requires both input arrays to have exactly 3 elements, got 4 and 4

```
@linrrzqqq linrrzqqq deleted the array-cross-product branch June 3, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/4.1.x dev/4.1.x-conflict reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants