Skip to content

[fix](timestamptz) Report TIMESTAMPTZ as string to MySQL clients#63292

Merged
zclllyybb merged 2 commits into
apache:masterfrom
zclllyybb:codex-doris-25709-repro
May 18, 2026
Merged

[fix](timestamptz) Report TIMESTAMPTZ as string to MySQL clients#63292
zclllyybb merged 2 commits into
apache:masterfrom
zclllyybb:codex-doris-25709-repro

Conversation

@zclllyybb
Copy link
Copy Markdown
Contributor

TIMESTAMPTZ result rows are serialized as timezone-aware strings in the MySQL binary protocol. FE metadata used to advertise them as MYSQL_TYPE_DATETIME, so Connector/J decoded the length-encoded string bytes as a MySQL datetime binary payload and failed with Invalid length (32) for type TIMESTAMP when ResultSet.getString read a server-prepared result.

Change PrimitiveType.toMysqlType() to return MYSQL_TYPE_STRING for TIMESTAMPTZ, adjust the field packet length and decimals to string semantics, and make the FE local binary result path write TIMESTAMPTZ through the string fallback instead of the datetime binary layout. BE serialization already uses push_timestamptz -> push_string, so no BE payload change is needed.

Add a field-packet unit test and a regression suite that forces ServerPreparedStatement and compares direct ResultSet.getString(ts) with CAST(ts AS STRING).

TIMESTAMPTZ result rows are serialized as timezone-aware strings in the MySQL binary protocol. FE metadata used to advertise them as MYSQL_TYPE_DATETIME, so Connector/J decoded the length-encoded string bytes as a MySQL datetime binary payload and failed with Invalid length (32) for type TIMESTAMP when ResultSet.getString read a server-prepared result.

Change PrimitiveType.toMysqlType() to return MYSQL_TYPE_STRING for TIMESTAMPTZ, adjust the field packet length and decimals to string semantics, and make the FE local binary result path write TIMESTAMPTZ through the string fallback instead of the datetime binary layout. BE serialization already uses push_timestamptz -> push_string, so no BE payload change is needed.

Add a field-packet unit test and a regression suite that forces ServerPreparedStatement and compares direct ResultSet.getString(ts) with CAST(ts AS STRING).

Verification:

- ./run-fe-ut.sh --run org.apache.doris.mysql.MysqlSerializerVarbinaryTest

- ./run-regression-test.sh --run -d datatype_p0/timestamptz -s test_timestamptz_jdbc_binary_protocol
@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?

@zclllyybb
Copy link
Copy Markdown
Contributor Author

/review

@zclllyybb
Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 31294 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit ecac99691a8c6cf44c8227369eceae6afb3cabb7, 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	17678	3935	3869	3869
q2	q3	10773	1393	805	805
q4	4684	467	349	349
q5	7550	2250	2105	2105
q6	233	174	141	141
q7	929	791	626	626
q8	9355	1675	1611	1611
q9	5152	4911	4871	4871
q10	6405	2057	1768	1768
q11	456	279	242	242
q12	639	425	302	302
q13	18111	3431	2761	2761
q14	271	253	232	232
q15	q16	825	778	707	707
q17	907	1012	861	861
q18	6970	5884	5546	5546
q19	1550	1282	1090	1090
q20	525	406	410	406
q21	6183	2823	2629	2629
q22	450	373	451	373
Total cold run time: 99646 ms
Total hot run time: 31294 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	4749	4541	4493	4493
q2	q3	4893	5252	4616	4616
q4	2169	2215	1404	1404
q5	5013	4678	4703	4678
q6	240	178	144	144
q7	1929	1712	1581	1581
q8	2533	2128	2118	2118
q9	7709	7388	7292	7292
q10	4495	4385	3961	3961
q11	546	394	352	352
q12	705	713	517	517
q13	3016	3382	2802	2802
q14	276	271	252	252
q15	q16	672	710	616	616
q17	1288	1270	1264	1264
q18	7364	6858	6728	6728
q19	1108	1107	1081	1081
q20	2217	2214	1911	1911
q21	5359	4748	4605	4605
q22	522	469	421	421
Total cold run time: 56803 ms
Total hot run time: 50836 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

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

query5	4347	659	526	526
query6	328	214	196	196
query7	4240	547	315	315
query8	336	236	217	217
query9	8851	4085	4053	4053
query10	447	338	305	305
query11	5807	2348	2199	2199
query12	188	128	126	126
query13	1285	653	433	433
query14	5973	5380	5047	5047
query14_1	4383	4375	4353	4353
query15	215	207	183	183
query16	1041	470	451	451
query17	1174	750	609	609
query18	2738	508	366	366
query19	234	216	174	174
query20	140	135	132	132
query21	223	140	120	120
query22	13579	13591	13331	13331
query23	17316	16466	16009	16009
query23_1	16257	16253	16155	16155
query24	7462	1783	1304	1304
query24_1	1303	1316	1299	1299
query25	592	504	448	448
query26	1322	330	174	174
query27	2680	593	353	353
query28	4457	1978	1974	1974
query29	1002	654	524	524
query30	309	246	202	202
query31	1117	1077	960	960
query32	89	79	81	79
query33	557	368	311	311
query34	1175	1179	654	654
query35	754	783	660	660
query36	1346	1344	1200	1200
query37	153	106	97	97
query38	3224	3157	3048	3048
query39	934	919	911	911
query39_1	887	877	865	865
query40	227	146	128	128
query41	68	63	62	62
query42	111	115	110	110
query43	324	327	277	277
query44	
query45	211	207	200	200
query46	1067	1190	714	714
query47	2323	2380	2194	2194
query48	396	405	295	295
query49	635	483	379	379
query50	959	346	252	252
query51	4325	4212	4221	4212
query52	112	107	97	97
query53	265	279	209	209
query54	334	294	258	258
query55	94	96	91	91
query56	305	308	314	308
query57	1431	1406	1326	1326
query58	301	270	277	270
query59	1554	1631	1407	1407
query60	312	314	315	314
query61	163	158	161	158
query62	670	644	562	562
query63	254	203	210	203
query64	2389	802	656	656
query65	
query66	1663	464	383	383
query67	30062	29891	29877	29877
query68	
query69	457	346	301	301
query70	992	985	995	985
query71	303	283	267	267
query72	3034	2774	2435	2435
query73	870	769	441	441
query74	5059	4902	4729	4729
query75	2692	2608	2247	2247
query76	2308	1115	756	756
query77	409	411	330	330
query78	12180	12091	11611	11611
query79	1484	1067	715	715
query80	662	558	467	467
query81	464	281	249	249
query82	1355	159	122	122
query83	348	280	245	245
query84	259	139	115	115
query85	890	540	459	459
query86	400	362	327	327
query87	3408	3388	3188	3188
query88	3542	2694	2667	2667
query89	443	390	333	333
query90	1987	182	183	182
query91	184	167	141	141
query92	77	76	70	70
query93	1463	1471	941	941
query94	516	352	316	316
query95	707	490	368	368
query96	1039	812	321	321
query97	2726	2669	2563	2563
query98	234	232	235	232
query99	1131	1093	1002	1002
Total cold run time: 253580 ms
Total hot run time: 169528 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 2.94% (1/34) 🎉
Increment coverage report
Complete coverage report

@zclllyybb zclllyybb closed this May 17, 2026
@zclllyybb zclllyybb reopened this May 17, 2026
@zclllyybb
Copy link
Copy Markdown
Contributor Author

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Review Summary
No blocking findings identified in the GitHub PR diff. The change is focused on making TIMESTAMPTZ MySQL metadata match the string payload used by result serialization, and the added unit/regression coverage targets that behavior.

Critical checkpoint conclusions:

  • Goal and tests: The PR addresses the reported Connector/J binary protocol mismatch for TIMESTAMPTZ and includes FE metadata unit coverage plus a server-prepared JDBC regression test.
  • Scope: The effective PR diff is small and focused on TIMESTAMPTZ MySQL protocol metadata/result serialization behavior.
  • Concurrency and lifecycle: No new shared mutable state, locks, threads, or lifecycle-sensitive objects are introduced.
  • Configuration and compatibility: No new config items or persisted storage formats are added. The protocol metadata change is behavior-changing but aligned with the existing string row payload.
  • Parallel code paths: The relevant MysqlSerializer field metadata paths share the same helper methods; FE local binary rows now fall through to string serialization for TIMESTAMPTZ, matching BE row-buffer behavior.
  • Test coverage: The new tests cover field packet metadata and a server-prepared JDBC getString path. I did not run tests locally in this review runner.
  • Observability, transactions, FE-BE variables, data writes: Not applicable to this PR.
  • User focus: No additional user-provided review focus was present.

The TIMESTAMPTZ MySQL metadata fix now reports TIMESTAMPTZ columns as string fields to JDBC clients. That makes direct TIMESTAMPTZ query results use Doris' timezone-aware textual representation instead of the MySQL driver's previous ISO-style timestamp formatting.

Refresh the affected regression baselines for datatype TIMESTAMPTZ casts, date-function document cases, and the Paimon TIMESTAMPTZ external table case. The Paimon direct scanner outputs are aligned with the TeamCity external-regression real result and the corresponding cast output format.

Verification: ./run-regression-test.sh --conf /tmp/doris-regression-conf-9737.groovy --run -d datatype_p0/timestamptz -s test_timestamptz_cast; ./run-regression-test.sh --conf /tmp/doris-regression-conf-9737.groovy --run -d datatype_p0/timestamptz -s test_cast_timestamptz; ./run-regression-test.sh --conf /tmp/doris-regression-conf-9737.groovy --run -d doc/sql-manual/sql-functions -s doc_date_functions_test. All passed.
@zclllyybb
Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 31144 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 0a39514cc5bbab0119ae1899044d1447e36c2bff, 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	17666	3793	3794	3793
q2	q3	10876	1376	820	820
q4	4690	479	345	345
q5	7557	2287	2119	2119
q6	245	171	136	136
q7	922	756	620	620
q8	9470	1738	1641	1641
q9	6604	4883	4881	4881
q10	6441	2086	1774	1774
q11	428	279	239	239
q12	692	424	308	308
q13	18172	3350	2765	2765
q14	264	253	238	238
q15	q16	824	769	700	700
q17	1031	848	921	848
q18	6967	5737	5568	5568
q19	1228	1283	1216	1216
q20	562	426	267	267
q21	6096	2731	2548	2548
q22	461	395	318	318
Total cold run time: 101196 ms
Total hot run time: 31144 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	4642	4462	4669	4462
q2	q3	4808	5262	4610	4610
q4	2120	2192	1377	1377
q5	4846	4645	4594	4594
q6	229	170	130	130
q7	1886	1717	1523	1523
q8	2248	1883	1864	1864
q9	7200	7144	7127	7127
q10	4470	4397	3955	3955
q11	522	384	346	346
q12	719	715	523	523
q13	3031	3344	2770	2770
q14	268	277	255	255
q15	q16	674	697	607	607
q17	1247	1214	1215	1214
q18	7184	7056	6831	6831
q19	1103	1086	1096	1086
q20	2210	2202	1940	1940
q21	5295	4571	4456	4456
q22	526	456	428	428
Total cold run time: 55228 ms
Total hot run time: 50098 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 169912 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 0a39514cc5bbab0119ae1899044d1447e36c2bff, data reload: false

query5	4334	659	515	515
query6	350	222	205	205
query7	4262	552	320	320
query8	336	228	217	217
query9	8839	3950	3961	3950
query10	450	342	292	292
query11	5840	2350	2163	2163
query12	180	126	121	121
query13	1240	610	427	427
query14	5988	5351	5033	5033
query14_1	4318	4360	4278	4278
query15	203	202	179	179
query16	1000	468	420	420
query17	1125	702	581	581
query18	2435	480	366	366
query19	218	208	170	170
query20	138	133	132	132
query21	218	142	119	119
query22	13727	13596	13342	13342
query23	17104	16371	15989	15989
query23_1	16262	16151	16174	16151
query24	7518	1762	1305	1305
query24_1	1326	1340	1344	1340
query25	582	507	450	450
query26	1330	331	179	179
query27	2667	556	339	339
query28	4461	1970	1941	1941
query29	1010	628	527	527
query30	325	243	200	200
query31	1115	1068	942	942
query32	89	78	75	75
query33	553	362	329	329
query34	1186	1135	642	642
query35	765	782	685	685
query36	1354	1323	1180	1180
query37	155	136	92	92
query38	3206	3128	3052	3052
query39	931	926	886	886
query39_1	888	874	890	874
query40	226	146	127	127
query41	65	61	61	61
query42	111	109	118	109
query43	329	329	283	283
query44	
query45	207	199	193	193
query46	1034	1164	705	705
query47	2281	2361	2182	2182
query48	395	393	282	282
query49	628	482	380	380
query50	1006	357	238	238
query51	4316	4317	4249	4249
query52	103	106	93	93
query53	257	284	213	213
query54	320	266	250	250
query55	97	90	83	83
query56	300	302	302	302
query57	1395	1424	1359	1359
query58	291	268	262	262
query59	1543	1632	1373	1373
query60	314	314	309	309
query61	154	156	144	144
query62	676	618	552	552
query63	251	201	202	201
query64	2410	788	630	630
query65	
query66	1747	473	355	355
query67	30082	29876	29869	29869
query68	
query69	466	335	297	297
query70	987	998	989	989
query71	299	278	258	258
query72	2950	2850	2551	2551
query73	850	744	400	400
query74	5049	4899	4725	4725
query75	2709	2623	2239	2239
query76	2297	1146	764	764
query77	400	405	325	325
query78	12106	11963	11519	11519
query79	1449	1012	705	705
query80	640	557	445	445
query81	461	288	238	238
query82	1382	155	123	123
query83	350	274	246	246
query84	262	141	109	109
query85	879	522	439	439
query86	391	354	340	340
query87	3366	3409	3213	3213
query88	3522	2659	2659	2659
query89	435	384	334	334
query90	1974	173	174	173
query91	176	172	140	140
query92	76	76	72	72
query93	1535	1418	950	950
query94	534	338	300	300
query95	673	479	348	348
query96	1064	749	352	352
query97	2688	2687	2573	2573
query98	235	225	221	221
query99	1164	1098	958	958
Total cold run time: 252884 ms
Total hot run time: 169912 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 100.00% (1/1) 🎉
Increment coverage report
Complete coverage report

@zclllyybb
Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label May 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Reviewed the GitHub PR diff (TIMESTAMPTZ MySQL/JDBC metadata and regression output updates). I did not find blocking issues.\n\nCritical checkpoint conclusions:\n- Goal/test coverage: The change reports TIMESTAMPTZ as string metadata and adds FE unit plus JDBC server-prepared regression coverage for ResultSet.getString; related baselines are updated.\n- Scope/focus: The actual PR diff is focused on TIMESTAMPTZ MySQL protocol metadata and expected output changes.\n- Concurrency/lifecycle: No new concurrency or lifecycle-sensitive code paths were introduced.\n- Configuration/compatibility: No new config items; this is a user-visible protocol metadata/output behavior change and the tests cover the intended new behavior.\n- Parallel paths: FE local binary result serialization and type metadata were both updated; BE already serializes TIMESTAMPTZ as strings.\n- Data correctness/transactions/persistence: No transaction, persistence, or storage visibility paths are changed.\n- Performance/observability: No meaningful performance impact or additional observability need identified.\n- User focus: No additional user-provided focus points were supplied.

@zclllyybb zclllyybb merged commit b9f5281 into apache:master May 18, 2026
33 checks passed
@zclllyybb zclllyybb deleted the codex-doris-25709-repro branch May 18, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants