You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "byBit-ovo (via GitHub)" <gi...@apache.org> on 2026/03/29 08:27:36 UTC

[PR] New feature/hmrs [doris]

byBit-ovo opened a new pull request, #61850:
URL: https://github.com/apache/doris/pull/61850

   ### 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 <!-- At least one of them must be included. -->
       - [ ] 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 <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [ ] No.
       - [ ] Yes. https://github.com/apache/doris-website/pull/3501
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [Enhancement] support simple sql function from Trino&Presto [doris]

Posted by "prakash-atul (via GitHub)" <gi...@apache.org>.
prakash-atul commented on PR #61850:
URL: https://github.com/apache/doris/pull/61850#issuecomment-4587559070

   Hi @zclllyybb , the PR is ready for review.
   
   I addressed the previous review feedback and aligned the implementation with Presto/Trino semantics. I also added FE/BE unit tests, regression tests, and FE/BE consistency validation.
   
   https://github.com/apache/doris/pull/63923
   
   Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [Enhancement] support simple sql function from Trino&Presto [doris]

Posted by "zclllyybb (via GitHub)" <gi...@apache.org>.
zclllyybb commented on PR #61850:
URL: https://github.com/apache/doris/pull/61850#issuecomment-4583053857

   > @zclllyybb Hi, I noticed this PR has been inactive for more than a month after review feedback. If there’s no objection, I’d like to continue working on `human_readable_seconds` and submit a fresh PR.
   
   welcome! I think now you can quickly complete a high-quality PR through AI, but please pay attention to performance, test coverage, and usage conventions. let me know when the PR is ready~


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [Enhancement] support simple sql function from Trino&Presto [doris]

Posted by "prakash-atul (via GitHub)" <gi...@apache.org>.
prakash-atul commented on PR #61850:
URL: https://github.com/apache/doris/pull/61850#issuecomment-4581749497

   Hi, I noticed this PR has been inactive for more than a month after review feedback. If there’s no objection, I’d like to continue working on `human_readable_seconds` and submit a fresh PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [Enhancement] support simple sql function from Trino&Presto [doris]

Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #61850:
URL: https://github.com/apache/doris/pull/61850#issuecomment-4152483452

   
   <details>
   <summary>TPC-H: <b>Total hot run time: 26655 ms</b></summary>
   
   ```
   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
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] New feature/hmrs [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #61850:
URL: https://github.com/apache/doris/pull/61850#issuecomment-4149696278

   
   Thank you for your contribution to Apache Doris.
   Don't know what should be done next? See [How to process your PR](https://cwiki.apache.org/confluence/display/DORIS/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?
       


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [Enhancement] support simple sql function from Trino&Presto [doris]

Posted by "gavinchou (via GitHub)" <gi...@apache.org>.
gavinchou commented on PR #61850:
URL: https://github.com/apache/doris/pull/61850#issuecomment-4152401511

   run buildall


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [Enhancement] support simple sql function from Trino&Presto [doris]

Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #61850:
URL: https://github.com/apache/doris/pull/61850#issuecomment-4152524739

   
   <details>
   <summary>TPC-DS: <b>Total hot run time: 168752 ms</b></summary>
   
   ```
   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
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [Enhancement] support simple sql function from Trino&Presto [doris]

Posted by "zclllyybb (via GitHub)" <gi...@apache.org>.
zclllyybb commented on code in PR #61850:
URL: https://github.com/apache/doris/pull/61850#discussion_r3007992852


##########
be/src/exprs/function/function_utility.cpp:
##########
@@ -138,11 +141,124 @@ class FunctionVersion : public IFunction {
     }
 };
 
+class FunctionHumanReadableSeconds : public IFunction {
+public:
+    static constexpr auto name = "human_readable_seconds";
+
+    static FunctionPtr create() { return std::make_shared<FunctionHumanReadableSeconds>(); }
+
+    String get_name() const override { return name; }
+
+    size_t get_number_of_arguments() const override { return 1; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& /*arguments*/) const override {
+        return std::make_shared<DataTypeString>();
+    }
+
+    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();

Review Comment:
   no need to do this. the outer framework did.



##########
be/src/exprs/function/function_utility.cpp:
##########
@@ -138,11 +141,124 @@ class FunctionVersion : public IFunction {
     }
 };
 
+class FunctionHumanReadableSeconds : public IFunction {
+public:
+    static constexpr auto name = "human_readable_seconds";
+
+    static FunctionPtr create() { return std::make_shared<FunctionHumanReadableSeconds>(); }
+
+    String get_name() const override { return name; }
+
+    size_t get_number_of_arguments() const override { return 1; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& /*arguments*/) const override {
+        return std::make_shared<DataTypeString>();
+    }
+
+    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();
+        const auto* data_column = check_and_get_column<ColumnFloat64>(*argument_column);
+        if (data_column == nullptr) {
+            return Status::InvalidArgument("Illegal column {} of first argument of function {}",
+                                           argument_column->get_name(), name);
+        }
+
+        auto result_column = ColumnString::create();
+        for (size_t i = 0; i < input_rows_count; ++i) {
+            auto value = data_column->get_element(i);
+            auto text = _to_human_readable(value);
+            result_column->insert_data(text.data(), text.size());
+        }
+
+        block.replace_by_position(result, std::move(result_column));
+        return Status::OK();
+    }
+
+private:
+    static std::string _append_unit(int64_t value, const char* singular, const char* plural) {
+        return std::to_string(value) + " " + (value == 1 ? singular : plural);
+    }
+
+    static std::string _to_human_readable(double seconds) {

Review Comment:
   dont pass string as result. directly write to result column



##########
regression-test/suites/query_p0/sql_functions/datetime_functions/test_human_readable_seconds.groovy:
##########


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



##########
regression-test/suites/query_p0/sql_functions/datetime_functions/test_human_readable_seconds.groovy:
##########


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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org