Skip to content

[Enhancement] support simple sql function from Trino&Presto#61850

Open
byBit-ovo wants to merge 4 commits intoapache:masterfrom
byBit-ovo:new_feature/hmrs
Open

[Enhancement] support simple sql function from Trino&Presto#61850
byBit-ovo wants to merge 4 commits intoapache:masterfrom
byBit-ovo:new_feature/hmrs

Conversation

@byBit-ovo
Copy link
Copy Markdown

What problem does this PR solve?

Issue Number: #48203

Related PR: #N/A

Problem Summary: support simple sql function human_readable_seconds ( from Trino&Presto )

Release note

with millisecond formatting support

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

@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?

@byBit-ovo byBit-ovo changed the title New feature/hmrs [Enhancement] support simple sql function from Trino&Presto Mar 29, 2026
@gavinchou
Copy link
Copy Markdown
Contributor

run buildall

@doris-robot
Copy link
Copy Markdown

TPC-H: Total hot run time: 26655 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 5ec923fd2c6b43868b3cb17e114d048af86c30c2, 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	17636	4602	4306	4306
q2	q3	10652	779	536	536
q4	4672	357	252	252
q5	7560	1215	1013	1013
q6	184	179	149	149
q7	777	837	676	676
q8	9301	1479	1331	1331
q9	4674	4718	4690	4690
q10	6256	1906	1649	1649
q11	460	258	237	237
q12	704	592	470	470
q13	18042	2726	1947	1947
q14	227	227	216	216
q15	q16	723	737	670	670
q17	728	834	453	453
q18	5911	5369	5324	5324
q19	1129	995	616	616
q20	539	508	388	388
q21	4699	1826	1438	1438
q22	361	294	423	294
Total cold run time: 95235 ms
Total hot run time: 26655 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	4835	4588	4613	4588
q2	q3	3843	4401	3823	3823
q4	898	1208	752	752
q5	4091	4389	4341	4341
q6	183	194	152	152
q7	1772	1668	1549	1549
q8	2535	2717	2525	2525
q9	7989	7359	7530	7359
q10	3768	3986	3605	3605
q11	513	430	440	430
q12	496	627	473	473
q13	2479	2950	2130	2130
q14	281	297	270	270
q15	q16	750	769	696	696
q17	1173	1380	1358	1358
q18	7030	6653	6473	6473
q19	917	981	935	935
q20	2070	2148	2015	2015
q21	3962	3471	3536	3471
q22	448	439	368	368
Total cold run time: 50033 ms
Total hot run time: 47313 ms

@doris-robot
Copy link
Copy Markdown

TPC-DS: Total hot run time: 168752 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 5ec923fd2c6b43868b3cb17e114d048af86c30c2, data reload: false

query5	4326	635	532	532
query6	330	224	203	203
query7	4222	463	257	257
query8	348	236	223	223
query9	8695	2725	2730	2725
query10	516	368	332	332
query11	6978	5082	4910	4910
query12	179	130	128	128
query13	1279	466	348	348
query14	5774	3774	3465	3465
query14_1	2776	2794	2785	2785
query15	204	192	172	172
query16	982	439	443	439
query17	851	703	589	589
query18	2436	431	340	340
query19	212	206	177	177
query20	134	122	125	122
query21	213	137	109	109
query22	13265	14065	14843	14065
query23	16637	16173	15979	15979
query23_1	15889	15636	15719	15636
query24	7156	1623	1196	1196
query24_1	1221	1230	1236	1230
query25	535	470	405	405
query26	1242	259	146	146
query27	2782	478	296	296
query28	4532	1860	1841	1841
query29	806	561	511	511
query30	305	229	190	190
query31	1017	934	875	875
query32	80	72	72	72
query33	514	322	281	281
query34	900	878	515	515
query35	645	682	598	598
query36	1072	1126	952	952
query37	139	92	84	84
query38	2975	2941	2866	2866
query39	875	831	811	811
query39_1	792	805	804	804
query40	229	155	133	133
query41	62	60	58	58
query42	261	253	252	252
query43	239	245	217	217
query44	
query45	192	190	178	178
query46	873	974	610	610
query47	2099	2165	2009	2009
query48	312	309	226	226
query49	643	447	387	387
query50	683	279	217	217
query51	4024	4071	4020	4020
query52	261	262	256	256
query53	286	335	289	289
query54	302	275	260	260
query55	89	89	83	83
query56	312	322	304	304
query57	1931	1751	1630	1630
query58	276	273	268	268
query59	2781	3001	2743	2743
query60	341	331	327	327
query61	180	179	179	179
query62	640	601	547	547
query63	311	287	277	277
query64	5121	1372	1095	1095
query65	
query66	1479	489	397	397
query67	24332	24269	24216	24216
query68	
query69	413	322	291	291
query70	905	890	979	890
query71	352	313	302	302
query72	3043	2840	2437	2437
query73	539	537	319	319
query74	9674	9590	9428	9428
query75	2863	2787	2457	2457
query76	2339	1030	672	672
query77	356	372	319	319
query78	10977	11167	10508	10508
query79	1096	782	576	576
query80	723	631	527	527
query81	493	260	226	226
query82	1353	158	120	120
query83	335	259	239	239
query84	303	117	95	95
query85	846	497	468	468
query86	372	312	289	289
query87	3169	3116	3071	3071
query88	3514	2650	2655	2650
query89	424	370	343	343
query90	1956	177	172	172
query91	175	158	133	133
query92	78	74	72	72
query93	912	857	511	511
query94	454	329	293	293
query95	568	346	380	346
query96	636	519	231	231
query97	2507	2477	2378	2378
query98	236	219	216	216
query99	1008	1007	918	918
Total cold run time: 249154 ms
Total hot run time: 168752 ms

Status execute_impl(FunctionContext* /*context*/, Block& block, const ColumnNumbers& arguments,
uint32_t result, size_t input_rows_count) const override {
const auto& argument_column =
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no need to do this. the outer framework did.

return std::to_string(value) + " " + (value == 1 ? singular : plural);
}

static std::string _to_human_readable(double seconds) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dont pass string as result. directly write to result column

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

need check of consistency between FE and BE. btw, please add more data for test.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

with AI, I think it's easy to make dozens or hundreds of different data to cover the results as much as possible

@zclllyybb zclllyybb self-assigned this Mar 30, 2026
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.

5 participants