Skip to content

Conversation

@ChenMiaoi
Copy link
Contributor

What problem does this PR solve?

Support the cot math function.

Related PR: #48203

Problem Summary:

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@Thearas
Copy link
Contributor

Thearas commented Jun 9, 2025

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?

@ChenMiaoi ChenMiaoi changed the title [feat](nereids, function, test) add the cot math function [Enhancement](nereids, function, test) add the cot math function Jun 9, 2025
@ChenMiaoi
Copy link
Contributor Author

run buildall

constexpr double epsilon = 1e-10;
double remainder = std::fmod(std::abs(x), M_PI);

return std::abs(x) < epsilon || std::abs(remainder) < epsilon ||
Copy link
Contributor

Choose a reason for hiding this comment

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

just std::abs(remainder) < epsilon maybe is enough? this check seems could cover other two conditions. could you confirm this?

Copy link
Contributor

Choose a reason for hiding this comment

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

also add some test with data in table

double value = first.getValue();
double remainder = Math.abs(value) % Math.PI;

if (Math.abs(value) < epsilon || Math.abs(remainder) < epsilon || Math.abs(remainder - Math.PI) < epsilon) {
Copy link
Contributor

Choose a reason for hiding this comment

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

seem with comment in BE

InputTypeSet input_types = {PrimitiveType::TYPE_DOUBLE};

DataSet data_set = {{{-1.0}, -0.6420926159343306}, {{0.5}, 1.830487721712452},
{{1.0}, 0.6420926159343306}, {{0.0}, Null()},
Copy link
Contributor

Choose a reason for hiding this comment

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

add a testcase return Null which input is not zero

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17602	5158	5070	5070
q2	1939	289	199	199
q3	10286	1271	773	773
q4	10214	1021	541	541
q5	7527	2396	2346	2346
q6	184	160	131	131
q7	889	763	612	612
q8	9309	1261	1088	1088
q9	6852	5114	5076	5076
q10	6906	2374	1993	1993
q11	484	322	303	303
q12	351	362	237	237
q13	17777	3719	3218	3218
q14	241	226	220	220
q15	558	503	503	503
q16	441	444	408	408
q17	655	861	410	410
q18	7562	7294	7232	7232
q19	1213	972	581	581
q20	372	378	238	238
q21	4266	3489	2538	2538
q22	1064	1030	962	962
Total cold run time: 106692 ms
Total hot run time: 34679 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5153	5405	5117	5117
q2	261	336	231	231
q3	2194	2668	2359	2359
q4	1455	1835	1356	1356
q5	4336	4410	4413	4410
q6	223	172	131	131
q7	2071	1937	1809	1809
q8	2643	2625	2555	2555
q9	7221	7099	7141	7099
q10	3107	3291	2851	2851
q11	569	531	512	512
q12	708	783	630	630
q13	3571	3933	3440	3440
q14	282	292	271	271
q15	525	483	497	483
q16	493	511	466	466
q17	1185	1564	1387	1387
q18	7449	7339	7189	7189
q19	814	836	981	836
q20	1939	1988	1846	1846
q21	4884	4479	4549	4479
q22	1099	1040	985	985
Total cold run time: 52182 ms
Total hot run time: 50442 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 189507 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 329d9e620db73b55516107c262b17bdf78ca62f3, data reload: false

query1	1013	404	431	404
query2	6562	1860	1886	1860
query3	6750	231	227	227
query4	26792	23900	23109	23109
query5	4338	627	477	477
query6	307	239	207	207
query7	4634	511	324	324
query8	277	247	225	225
query9	8619	2966	2987	2966
query10	478	347	285	285
query11	15719	15274	14923	14923
query12	166	112	117	112
query13	1671	595	466	466
query14	9453	6011	6069	6011
query15	215	209	186	186
query16	7635	647	488	488
query17	1212	747	631	631
query18	2054	417	323	323
query19	214	211	179	179
query20	126	125	120	120
query21	217	131	111	111
query22	4233	4211	4114	4114
query23	34195	33238	33430	33238
query24	8500	2461	2519	2461
query25	563	478	412	412
query26	903	278	154	154
query27	2704	542	366	366
query28	4268	2363	2341	2341
query29	691	598	449	449
query30	287	232	191	191
query31	917	852	745	745
query32	71	64	63	63
query33	557	384	341	341
query34	831	884	560	560
query35	799	830	758	758
query36	1012	1036	976	976
query37	116	105	78	78
query38	4315	4307	4183	4183
query39	1507	1457	1422	1422
query40	210	122	108	108
query41	58	56	53	53
query42	131	123	117	117
query43	562	581	533	533
query44	1422	894	907	894
query45	182	179	171	171
query46	918	1070	670	670
query47	1791	1857	1736	1736
query48	429	440	334	334
query49	723	528	419	419
query50	690	723	450	450
query51	4122	4313	4133	4133
query52	118	121	107	107
query53	248	263	203	203
query54	628	625	575	575
query55	92	83	90	83
query56	319	339	306	306
query57	1189	1223	1149	1149
query58	274	273	283	273
query59	2824	2934	2816	2816
query60	347	352	346	346
query61	130	127	133	127
query62	798	736	645	645
query63	233	195	202	195
query64	3521	1089	704	704
query65	4326	4270	4267	4267
query66	922	419	338	338
query67	16159	15909	15624	15624
query68	8621	982	593	593
query69	486	318	284	284
query70	1317	1226	1199	1199
query71	480	353	327	327
query72	5377	4846	4787	4787
query73	736	646	384	384
query74	9142	9231	8965	8965
query75	4029	3253	2798	2798
query76	3603	1173	750	750
query77	799	394	307	307
query78	10272	10457	9482	9482
query79	2038	995	643	643
query80	635	556	460	460
query81	496	264	223	223
query82	443	133	101	101
query83	273	277	264	264
query84	253	117	94	94
query85	789	424	331	331
query86	390	320	306	306
query87	4587	4615	4431	4431
query88	3404	2446	2469	2446
query89	396	356	306	306
query90	1892	222	216	216
query91	149	148	119	119
query92	82	66	60	60
query93	1572	1041	665	665
query94	665	397	301	301
query95	402	317	311	311
query96	546	598	300	300
query97	2749	2800	2690	2690
query98	239	214	218	214
query99	1676	1404	1288	1288
Total cold run time: 276825 ms
Total hot run time: 189507 ms

@doris-robot
Copy link

BE UT Coverage Report

Increment line coverage 100.00% (10/10) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 57.03% (15368/26947)
Line Coverage 46.12% (139445/302347)
Region Coverage 45.45% (70645/155449)
Branch Coverage 40.22% (37330/92816)

@zclllyybb
Copy link
Contributor

finished by another pr:#52872

@zclllyybb zclllyybb closed this Jul 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants