Skip to content

Conversation

@github-actions
Copy link
Contributor

Cherry-picked from #56023

…ma Consistency Issues (#56023)

### What problem does this PR solve?

Following PR #55404 which addressed incorrect schema results for Paimon
tables, this PR further optimizes the Paimon time travel implementation
by removing redundant code and fixing the critical issue where schema ID
and snapshot ID were fetched separately, causing consistency problems
and unnecessary I/O overhead.

  #### Key Problem Solved

The core challenge in Paimon time travel is efficiently constructing
tables with specified snapshot ID and schema ID. Previously, these were
fetched separately, causing unnecessary I/O overhead and potential
consistency issues.

  #### Major Improvements

  1. Performance Optimization 

- Unified schema and snapshot retrieval: Combined separate API calls for
schema ID and snapshot ID into a single operation
- Removed redundant metadata fetches: Eliminated duplicate calls to
Paimon metadata store
- Optimized branch schema handling: Streamlined branch-specific schema
resolution

  2. Bug Fixes

- Fixed timezone-related query errors: Resolved incorrect results when
using Paimon time travel syntax with non-UTC timezones
- Fixed branch schema consistency: Ensured snapshot ID and schema ID are
always fetched atomically to prevent mismatched metadata

3. Enhanced Timestamp Format Support for FOR TIME AS OF

  Now supports the following timestamp formats:
- YYYY-MM-DD HH:MM:SS.SSS - Full timestamp with milliseconds (e.g.,
2024-01-15 10:30:45.123)
- YYYY-MM-DD HH:MM:SS - Timestamp with seconds precision (e.g.,
2024-01-15 10:30:45)
- YYYY-MM-DD - Date only format (defaults to 00:00:00.000) (e.g.,
2024-01-15)

  Example usage:
  ```
  -- Using different timestamp formats
  SELECT * FROM paimon_table FOR TIME AS OF "2024-01-15 10:30:45.123";
  SELECT * FROM paimon_table FOR TIME AS OF "2024-01-15 10:30:45";
  SELECT * FROM paimon_table FOR TIME AS OF "2024-01-15";
  ```
@github-actions github-actions bot requested a review from morrySnow as a code owner September 23, 2025 04:45
@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?

@dataroaring dataroaring reopened this Sep 23, 2025
@hello-stephen
Copy link
Contributor

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17579	5474	5381	5381
q2	2037	402	295	295
q3	12320	1222	743	743
q4	10298	868	460	460
q5	9309	2383	2136	2136
q6	181	168	133	133
q7	873	748	609	609
q8	9352	1411	1136	1136
q9	5114	4995	4867	4867
q10	6755	2268	1808	1808
q11	480	283	261	261
q12	340	356	214	214
q13	17781	3604	2996	2996
q14	219	228	205	205
q15	524	470	461	461
q16	414	441	368	368
q17	614	846	375	375
q18	6922	6550	6519	6519
q19	1213	959	542	542
q20	335	340	211	211
q21	2853	2187	1951	1951
q22	1042	1031	965	965
Total cold run time: 106555 ms
Total hot run time: 32636 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5520	5445	5447	5445
q2	237	327	252	252
q3	2266	2605	2355	2355
q4	1399	1821	1351	1351
q5	4366	5023	5029	5023
q6	170	161	134	134
q7	2093	1963	1845	1845
q8	2654	2833	2676	2676
q9	7275	7439	7337	7337
q10	3060	3408	2775	2775
q11	583	521	523	521
q12	694	767	637	637
q13	3455	3844	3221	3221
q14	279	325	289	289
q15	521	490	484	484
q16	451	502	447	447
q17	1247	1756	1290	1290
q18	7790	7691	7555	7555
q19	819	1172	1102	1102
q20	2039	2096	1937	1937
q21	5394	4940	4688	4688
q22	1043	1078	1052	1052
Total cold run time: 53355 ms
Total hot run time: 52416 ms

@doris-robot
Copy link

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

query1	951	406	410	406
query2	6215	1954	1828	1828
query3	8687	199	194	194
query4	33760	23766	24029	23766
query5	4662	625	454	454
query6	293	215	179	179
query7	4229	519	330	330
query8	297	241	243	241
query9	9406	2592	2588	2588
query10	492	340	264	264
query11	18060	15448	15299	15299
query12	154	115	106	106
query13	1552	568	443	443
query14	8791	6642	7353	6642
query15	275	189	190	189
query16	8077	684	488	488
query17	1511	742	575	575
query18	2125	440	328	328
query19	236	198	160	160
query20	124	124	125	124
query21	206	138	110	110
query22	4693	4594	4693	4594
query23	35167	34607	34466	34466
query24	7279	2707	2756	2707
query25	559	502	427	427
query26	785	308	182	182
query27	2245	489	362	362
query28	5385	2219	2193	2193
query29	739	618	461	461
query30	240	197	164	164
query31	974	944	839	839
query32	89	58	61	58
query33	514	391	333	333
query34	780	939	544	544
query35	813	823	744	744
query36	1026	1056	968	968
query37	110	96	71	71
query38	4015	3995	3983	3983
query39	1586	1530	1537	1530
query40	217	130	113	113
query41	53	50	48	48
query42	124	113	109	109
query43	493	515	480	480
query44	1488	839	838	838
query45	191	178	171	171
query46	943	1117	699	699
query47	1961	1991	1931	1931
query48	436	436	379	379
query49	748	506	405	405
query50	751	736	450	450
query51	7304	7309	7242	7242
query52	103	104	95	95
query53	235	277	194	194
query54	564	560	480	480
query55	78	79	78	78
query56	274	264	247	247
query57	1279	1251	1253	1251
query58	236	229	233	229
query59	3051	3186	2989	2989
query60	301	289	263	263
query61	114	107	153	107
query62	815	750	698	698
query63	236	199	197	197
query64	3796	1006	637	637
query65	3373	3339	3342	3339
query66	857	416	311	311
query67	16687	15820	15601	15601
query68	7831	861	560	560
query69	495	313	275	275
query70	1199	1099	1103	1099
query71	422	310	267	267
query72	5214	3802	3917	3802
query73	641	791	357	357
query74	10314	9511	8965	8965
query75	3942	3182	2693	2693
query76	3478	1260	774	774
query77	776	385	275	275
query78	10263	10469	9622	9622
query79	3914	940	599	599
query80	758	543	433	433
query81	490	263	224	224
query82	327	127	90	90
query83	162	163	156	156
query84	285	100	87	87
query85	747	372	336	336
query86	351	321	300	300
query87	4315	4354	4288	4288
query88	3480	2441	2426	2426
query89	435	345	298	298
query90	2064	193	193	193
query91	136	147	109	109
query92	67	56	53	53
query93	2116	946	558	558
query94	668	441	299	299
query95	352	284	271	271
query96	494	675	288	288
query97	3223	3238	3137	3137
query98	230	204	205	204
query99	1506	1459	1344	1344
Total cold run time: 294505 ms
Total hot run time: 193303 ms

@doris-robot
Copy link

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

query1	0.03	0.04	0.03
query2	0.07	0.03	0.03
query3	0.23	0.07	0.07
query4	1.62	0.11	0.11
query5	0.51	0.50	0.51
query6	1.16	0.72	0.72
query7	0.02	0.02	0.02
query8	0.04	0.03	0.03
query9	0.57	0.50	0.49
query10	0.55	0.55	0.57
query11	0.16	0.12	0.10
query12	0.14	0.10	0.11
query13	0.63	0.60	0.60
query14	0.78	0.82	0.79
query15	0.85	0.85	0.82
query16	0.39	0.40	0.37
query17	1.01	1.00	1.07
query18	0.24	0.22	0.22
query19	1.90	1.82	1.83
query20	0.02	0.01	0.01
query21	15.40	0.97	0.57
query22	0.72	0.80	0.62
query23	15.16	1.42	0.54
query24	3.40	1.24	0.29
query25	0.14	0.08	0.04
query26	0.33	0.15	0.14
query27	0.06	0.05	0.05
query28	12.62	1.01	0.43
query29	12.64	3.88	3.25
query30	0.25	0.09	0.07
query31	2.82	0.60	0.39
query32	3.23	0.54	0.47
query33	2.98	3.03	3.07
query34	16.73	5.14	4.55
query35	4.60	4.54	4.54
query36	0.63	0.50	0.48
query37	0.08	0.06	0.06
query38	0.05	0.03	0.03
query39	0.04	0.02	0.03
query40	0.16	0.14	0.12
query41	0.08	0.03	0.02
query42	0.04	0.02	0.03
query43	0.04	0.03	0.03
Total cold run time: 103.12 s
Total hot run time: 28.14 s

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

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

@morrySnow morrySnow merged commit 62ee0c8 into branch-3.1 Sep 25, 2025
23 of 24 checks passed
@morrySnow morrySnow deleted the auto-pick-56023-branch-3.1 branch September 25, 2025 09:33
@morrySnow morrySnow mentioned this pull request Oct 23, 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.

5 participants