Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Support some math functions #48476

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ChenMiaoi
Copy link

@ChenMiaoi ChenMiaoi commented Feb 28, 2025

What problem does this PR solve?

Related PR: #48203

Problem Summary: support simple sql function for sinh(from Trino), asinh, atanh, acosh

Release note

None

Check List (For Author)

Check List (For Reviewer who merge this PR)

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

@hello-stephen
Copy link
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?

Copy link
Contributor

@morrySnow morrySnow left a comment

Choose a reason for hiding this comment

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

please add fe impl in org.apache.doris.nereids.trees.expressions.functions.executable.NumericArithmetic
and add fe constant folding in
regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_numeric_arithmatic.groovy

* ScalarFunction atanh
*/
public class Atanh extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable, PropagateNullLiteral {
Copy link
Contributor

Choose a reason for hiding this comment

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

why impl both AlwaysNullable and PropagateNullLiteral?

Copy link
Author

Choose a reason for hiding this comment

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

I referred Acos, and the AlwaysNullable for the atanh input like $x = -1$, it will make output be null, and PropagateNullLiteral for $input = null$. does this lead to duplication?

ChenMiaoi added a commit to ChenMiaoi/doris that referenced this pull request Feb 28, 2025
@ChenMiaoi ChenMiaoi force-pushed the feature/math-trigonometric branch from b7a640e to 282a37c Compare February 28, 2025 15:25
@ChenMiaoi
Copy link
Author

please add fe impl in org.apache.doris.nereids.trees.expressions.functions.executable.NumericArithmetic and add fe constant folding in regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_numeric_arithmatic.groovy

already supported

Copy link
Contributor

github-actions bot commented Mar 6, 2025

PR approved by anyone and no changes requested.

@LiBinfeng-01
Copy link
Collaborator

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17734	5361	5228	5228
q2	2044	291	170	170
q3	10427	1267	797	797
q4	10260	1062	543	543
q5	7813	2432	2416	2416
q6	199	172	137	137
q7	921	781	615	615
q8	9315	1345	1145	1145
q9	4962	4870	4925	4870
q10	6855	2329	1887	1887
q11	468	284	265	265
q12	357	370	234	234
q13	17751	3719	3094	3094
q14	231	228	214	214
q15	539	501	503	501
q16	624	609	574	574
q17	598	889	354	354
q18	6935	6490	6448	6448
q19	1201	987	568	568
q20	324	334	200	200
q21	3011	2198	2048	2048
q22	1085	1042	1006	1006
Total cold run time: 103654 ms
Total hot run time: 33314 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5304	5245	5227	5227
q2	243	337	230	230
q3	2197	2673	2343	2343
q4	1459	1852	1382	1382
q5	4258	4158	4161	4158
q6	211	167	128	128
q7	2012	1919	1795	1795
q8	2658	2682	2643	2643
q9	7349	7250	7222	7222
q10	3070	3254	2804	2804
q11	585	526	485	485
q12	682	740	566	566
q13	3552	3933	3285	3285
q14	286	303	293	293
q15	540	498	482	482
q16	646	680	660	660
q17	1199	1645	1360	1360
q18	7750	7610	7474	7474
q19	880	948	1112	948
q20	2013	2032	1882	1882
q21	5600	5044	4816	4816
q22	1175	1078	1029	1029
Total cold run time: 53669 ms
Total hot run time: 51212 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 193240 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 b095acbdb0c389a20270f32d6336f7d2790e2942, data reload: false

query1	1387	1046	1017	1017
query2	6102	1935	1991	1935
query3	11115	4755	4635	4635
query4	55775	26291	23256	23256
query5	5043	555	523	523
query6	337	227	206	206
query7	4863	511	297	297
query8	308	263	242	242
query9	5446	2586	2587	2586
query10	429	327	253	253
query11	15099	15135	15312	15135
query12	166	109	112	109
query13	1023	519	387	387
query14	11081	6776	7003	6776
query15	218	201	180	180
query16	7100	708	498	498
query17	1105	746	581	581
query18	1446	414	334	334
query19	223	205	185	185
query20	139	129	127	127
query21	211	170	105	105
query22	4297	4581	4514	4514
query23	34025	33261	33253	33253
query24	6045	2434	2435	2434
query25	480	474	400	400
query26	712	290	152	152
query27	1822	497	336	336
query28	2888	2487	2462	2462
query29	590	563	455	455
query30	280	221	201	201
query31	884	841	803	803
query32	71	63	61	61
query33	484	375	303	303
query34	796	866	509	509
query35	821	845	807	807
query36	941	1016	912	912
query37	120	97	77	77
query38	4284	4302	4305	4302
query39	1507	1503	1463	1463
query40	207	111	108	108
query41	52	51	50	50
query42	125	110	102	102
query43	534	541	517	517
query44	1332	814	807	807
query45	199	182	166	166
query46	862	1053	643	643
query47	1831	1820	1813	1813
query48	406	425	326	326
query49	711	504	422	422
query50	707	756	450	450
query51	4327	4288	4253	4253
query52	110	106	100	100
query53	229	269	188	188
query54	513	504	440	440
query55	88	83	85	83
query56	263	282	266	266
query57	1135	1207	1112	1112
query58	270	239	247	239
query59	2756	3017	2673	2673
query60	283	276	268	268
query61	124	121	122	121
query62	750	748	681	681
query63	233	184	194	184
query64	2404	1036	689	689
query65	4521	4497	4441	4441
query66	770	391	294	294
query67	15738	15577	15342	15342
query68	7411	884	503	503
query69	537	321	314	314
query70	1238	1145	1101	1101
query71	492	297	258	258
query72	6000	3725	3758	3725
query73	1478	751	339	339
query74	9106	9119	8945	8945
query75	3804	3188	2724	2724
query76	4181	1187	739	739
query77	647	363	278	278
query78	10023	10113	9247	9247
query79	2393	873	597	597
query80	700	547	436	436
query81	469	267	232	232
query82	672	132	93	93
query83	259	169	149	149
query84	290	95	72	72
query85	770	345	307	307
query86	375	308	275	275
query87	4396	4353	4347	4347
query88	3482	2195	2197	2195
query89	429	326	289	289
query90	1911	198	196	196
query91	147	141	105	105
query92	73	61	56	56
query93	1508	1066	585	585
query94	655	411	307	307
query95	347	323	263	263
query96	494	565	267	267
query97	3344	3367	3246	3246
query98	236	211	197	197
query99	1464	1426	1264	1264
Total cold run time: 300474 ms
Total hot run time: 193240 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 31.43 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit b095acbdb0c389a20270f32d6336f7d2790e2942, data reload: false

query1	0.04	0.04	0.04
query2	0.08	0.03	0.03
query3	0.24	0.06	0.06
query4	1.62	0.10	0.10
query5	0.55	0.55	0.55
query6	1.20	0.73	0.72
query7	0.02	0.02	0.02
query8	0.05	0.03	0.04
query9	0.60	0.53	0.54
query10	0.56	0.57	0.55
query11	0.15	0.11	0.11
query12	0.15	0.11	0.12
query13	0.61	0.60	0.59
query14	2.66	2.80	2.83
query15	0.95	0.86	0.85
query16	0.38	0.38	0.37
query17	0.98	1.01	1.05
query18	0.20	0.20	0.20
query19	1.93	1.84	2.01
query20	0.01	0.01	0.01
query21	15.39	0.88	0.53
query22	0.75	1.15	0.96
query23	14.70	1.41	0.64
query24	6.81	0.93	1.82
query25	0.53	0.12	0.14
query26	0.57	0.16	0.14
query27	0.04	0.05	0.05
query28	9.78	0.85	0.44
query29	12.58	3.93	3.24
query30	0.25	0.10	0.06
query31	2.82	0.60	0.40
query32	3.23	0.55	0.48
query33	2.95	3.02	3.04
query34	15.79	5.20	4.55
query35	4.56	4.56	4.56
query36	0.66	0.49	0.48
query37	0.10	0.06	0.06
query38	0.06	0.03	0.03
query39	0.03	0.02	0.02
query40	0.17	0.13	0.13
query41	0.08	0.02	0.03
query42	0.03	0.02	0.02
query43	0.04	0.03	0.03
Total cold run time: 104.9 s
Total hot run time: 31.43 s

@doris-robot
Copy link

BE UT Coverage Report

Increment line coverage 21.43% (6/28) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 45.94% (12280/26729)
Line Coverage 35.40% (103701/292937)
Region Coverage 34.56% (53110/153687)
Branch Coverage 30.25% (26899/88918)

Copy link
Contributor

@zclllyybb zclllyybb left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants