Skip to content

[fix](point-query) Fix point query ignoring session timezone for functions like from_unixtime#60913

Open
eldenmoon wants to merge 1 commit intoapache:masterfrom
eldenmoon:pq-time
Open

[fix](point-query) Fix point query ignoring session timezone for functions like from_unixtime#60913
eldenmoon wants to merge 1 commit intoapache:masterfrom
eldenmoon:pq-time

Conversation

@eldenmoon
Copy link
Member

Point queries on unique key tables with row store incorrectly used the default timezone (Asia/Shanghai) instead of the session timezone when evaluating timezone-sensitive functions like from_unixtime(). This was because PTabletKeyLookupRequest did not carry timezone information, and the RuntimeState created in Reusable::init() always used the default timezone.

The fix adds a time_zone field to PTabletKeyLookupRequest, sets it from the session variable in FE PointQueryExecutor, and applies it to the RuntimeState in BE PointQueryExecutor::init().

Changes:

  • gensrc/proto: Add time_zone field to PTabletKeyLookupRequest
  • FE: Send session timezone in PointQueryExecutor.getNextInternal()
  • BE: Add RuntimeState::set_timezone() and use it in PointQueryExecutor::init()
  • Add regression test for point query timezone handling

…tions like from_unixtime

Point queries on unique key tables with row store incorrectly used the
default timezone (Asia/Shanghai) instead of the session timezone when
evaluating timezone-sensitive functions like from_unixtime(). This was
because PTabletKeyLookupRequest did not carry timezone information, and
the RuntimeState created in Reusable::init() always used the default
timezone.

The fix adds a time_zone field to PTabletKeyLookupRequest, sets it
from the session variable in FE PointQueryExecutor, and applies it to
the RuntimeState in BE PointQueryExecutor::init().

Changes:
- gensrc/proto: Add time_zone field to PTabletKeyLookupRequest
- FE: Send session timezone in PointQueryExecutor.getNextInternal()
- BE: Add RuntimeState::set_timezone() and use it in PointQueryExecutor::init()
- Add regression test for point query timezone handling
Copilot AI review requested due to automatic review settings February 28, 2026 09:13
@Thearas
Copy link
Contributor

Thearas commented Feb 28, 2026

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?

@eldenmoon
Copy link
Member Author

run buildall

@eldenmoon
Copy link
Member Author

run buildall

@eldenmoon eldenmoon added dev/4.0.x usercase Important user case type label labels Feb 28, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes point-query execution so timezone-sensitive functions (e.g., from_unixtime) respect the session timezone instead of the BE default timezone during short-circuit lookups on unique-key row-store tables.

Changes:

  • Adds time_zone to PTabletKeyLookupRequest and sends it from FE point-query execution.
  • Applies the request timezone to the BE RuntimeState during point-query initialization.
  • Adds a regression test verifying full-scan vs point-query timezone consistency.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
regression-test/suites/point_query_p0/test_point_query_timezone.groovy New regression suite covering point-query timezone behavior.
regression-test/data/point_query_p0/test_point_query_timezone.out Golden output for the new timezone regression test.
gensrc/proto/internal_service.proto Extends point-query request proto with time_zone.
fe/fe-core/src/main/java/org/apache/doris/qe/PointQueryExecutor.java Populates time_zone from session variables in point-query RPC.
be/src/service/point_query_executor.cpp Applies request timezone to the cached/reused runtime state.
be/src/runtime/runtime_state.h Adds RuntimeState::set_timezone() helper to update timezone state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hello-stephen
Copy link
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 79.35% (1798/2266)
Line Coverage 64.74% (32176/49697)
Region Coverage 65.60% (16096/24537)
Branch Coverage 56.12% (8576/15282)

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 0.00% (0/4) 🎉
Increment coverage report
Complete coverage report

1 similar comment
@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 0.00% (0/4) 🎉
Increment coverage report
Complete coverage report

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
============================================
q1	17634	4685	4452	4452
q2	q3	10728	809	538	538
q4	4737	372	257	257
q5	8098	1242	1031	1031
q6	215	178	149	149
q7	819	852	675	675
q8	10531	1469	1349	1349
q9	6825	4865	4760	4760
q10	6868	1899	1648	1648
q11	473	272	243	243
q12	784	570	470	470
q13	17788	4261	3448	3448
q14	234	233	220	220
q15	949	801	827	801
q16	732	750	687	687
q17	756	883	406	406
q18	6211	5312	5227	5227
q19	1155	1011	898	898
q20	611	553	450	450
q21	4543	2008	1443	1443
q22	350	291	276	276
Total cold run time: 101041 ms
Total hot run time: 29428 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4841	4782	4645	4645
q2	q3	1837	2249	1785	1785
q4	869	1212	773	773
q5	4073	4384	4438	4384
q6	189	180	144	144
q7	1858	1612	1524	1524
q8	2514	2763	2601	2601
q9	7522	7449	7281	7281
q10	2732	2809	2546	2546
q11	535	439	411	411
q12	523	579	465	465
q13	4156	4467	3698	3698
q14	286	305	286	286
q15	884	829	839	829
q16	753	819	739	739
q17	1284	1548	1362	1362
q18	7162	6833	6550	6550
q19	917	901	894	894
q20	2090	2175	2056	2056
q21	3973	3530	3337	3337
q22	471	419	396	396
Total cold run time: 49469 ms
Total hot run time: 46706 ms

@doris-robot
Copy link

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

query5	4726	663	510	510
query6	322	218	245	218
query7	4234	476	266	266
query8	339	270	249	249
query9	8742	2765	2801	2765
query10	484	377	351	351
query11	17069	17644	17317	17317
query12	201	145	146	145
query13	1716	491	363	363
query14	6855	3383	3087	3087
query14_1	2972	2952	2976	2952
query15	216	204	196	196
query16	1065	495	483	483
query17	1167	728	622	622
query18	4043	443	346	346
query19	204	220	175	175
query20	137	132	131	131
query21	218	145	126	126
query22	5510	4896	4890	4890
query23	17304	16930	16603	16603
query23_1	16678	16740	16792	16740
query24	7114	1624	1234	1234
query24_1	1234	1237	1216	1216
query25	557	462	395	395
query26	1226	273	158	158
query27	2777	464	294	294
query28	4457	1890	1900	1890
query29	822	568	470	470
query30	313	241	211	211
query31	901	723	654	654
query32	81	70	72	70
query33	506	341	284	284
query34	908	923	563	563
query35	646	671	593	593
query36	1036	1115	993	993
query37	137	93	86	86
query38	2950	2995	2904	2904
query39	881	867	856	856
query39_1	819	839	845	839
query40	231	155	136	136
query41	76	59	57	57
query42	106	100	100	100
query43	368	386	346	346
query44	
query45	198	187	190	187
query46	880	988	614	614
query47	2105	2105	2057	2057
query48	313	312	232	232
query49	661	463	387	387
query50	672	281	219	219
query51	4151	4131	4164	4131
query52	110	109	95	95
query53	299	340	284	284
query54	283	266	288	266
query55	92	89	81	81
query56	314	308	307	307
query57	1347	1328	1255	1255
query58	293	278	276	276
query59	2677	2815	2595	2595
query60	342	354	315	315
query61	145	147	149	147
query62	593	587	530	530
query63	318	282	270	270
query64	4880	1291	1011	1011
query65	
query66	1396	452	357	357
query67	16494	16438	16331	16331
query68	
query69	398	311	300	300
query70	991	975	965	965
query71	333	313	306	306
query72	2899	2896	2594	2594
query73	546	560	324	324
query74	9970	9965	9778	9778
query75	2870	2785	2507	2507
query76	2329	1048	701	701
query77	373	459	316	316
query78	11316	11548	10777	10777
query79	1279	798	603	603
query80	1366	656	602	602
query81	578	281	256	256
query82	1029	148	112	112
query83	338	257	245	245
query84	251	112	96	96
query85	877	494	449	449
query86	414	337	312	312
query87	3068	3085	3085	3085
query88	3582	2666	2648	2648
query89	426	373	349	349
query90	1982	173	173	173
query91	164	155	142	142
query92	75	82	67	67
query93	1096	872	506	506
query94	631	334	295	295
query95	587	393	312	312
query96	640	529	233	233
query97	2490	2488	2443	2443
query98	235	227	222	222
query99	1010	989	900	900
Total cold run time: 256748 ms
Total hot run time: 185088 ms

// serilized from TQueryOptions
optional bytes query_options = 8;
// timezone string, e.g. "America/Mexico_City"
optional string time_zone = 9;
Copy link
Contributor

Choose a reason for hiding this comment

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

should we directly pass a whole TQueryGlobals?

@hello-stephen
Copy link
Contributor

BE UT Coverage Report

Increment line coverage 0.00% (0/7) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.57% (19628/37338)
Line Coverage 36.19% (183258/506366)
Region Coverage 32.48% (142147/437579)
Branch Coverage 33.45% (61666/184368)

@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (7/7) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.62% (26185/36560)
Line Coverage 54.38% (274521/504813)
Region Coverage 51.78% (228731/441716)
Branch Coverage 53.08% (98170/184932)

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.

6 participants