Skip to content

[fix](TIMESTAMPTZ) serialize TIMESTAMPTZ schema change defaults with offset#63290

Open
Mryange wants to merge 3 commits into
apache:masterfrom
Mryange:TIMESTAMPTZ-schema-change-defaults
Open

[fix](TIMESTAMPTZ) serialize TIMESTAMPTZ schema change defaults with offset#63290
Mryange wants to merge 3 commits into
apache:masterfrom
Mryange:TIMESTAMPTZ-schema-change-defaults

Conversation

@Mryange
Copy link
Copy Markdown
Contributor

@Mryange Mryange commented May 15, 2026

What problem does this PR solve?

Issue Number: N/A

Problem Summary:

Schema change could fail when adding a TIMESTAMPTZ column with DEFAULT CURRENT_TIMESTAMP, such as ALTER TABLE ... ADD COLUMN ts TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP(6). Existing rows are backfilled from Column.realDefaultValue during schema change, but FE previously materialized CURRENT_TIMESTAMP as a plain datetime string without a timezone offset. Root cause: the schema-change default serialization path was not type-aware for TIMESTAMPTZ, while BE expects a TIMESTAMPTZ literal with an offset when parsing the backfill value. This change makes both the Nereids and legacy ColumnDef paths materialize TIMESTAMPTZ CURRENT_TIMESTAMP defaults with the session offset, reuses TimestampTzLiteral formatting for the datetime body, and adds FE and regression coverage for the schema-change path.

Release note

None

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?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented May 15, 2026

/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 completed. The FE serialization change is focused and appears to address the schema-change TIMESTAMPTZ CURRENT_TIMESTAMP backfill path by materializing a type-aware realDefaultValue with timezone information. I did not find duplicate existing review context or any additional user focus points.

Critical checkpoint conclusions:

  • Goal/test proof: The change targets schema change backfill for TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP and adds both FE unit coverage and a regression test, but the new regression test needs to comply with Doris regression-test standards before merge.
  • Scope: The production code change is small and localized to default-value materialization/formatting.
  • Concurrency/lifecycle: No new concurrency, locks, static initialization dependency, or lifecycle-sensitive state was introduced.
  • Config/compatibility/protocol: No new config or FE-BE protocol/storage format compatibility change was introduced; the existing column default string sent to BE remains the mechanism.
  • Parallel paths: Both Nereids schema-change and legacy ColumnDef materialization paths were considered; no additional functional path requiring the same fix was found in this PR.
  • Tests/results: Coverage was added, but the regression test currently violates required test-case conventions.
  • Observability: No new observability is required for this localized serialization fix.
  • Transaction/persistence/data correctness: The change affects persisted Column.realDefaultValue for schema change; the materialized value is deterministic for existing-row backfill and does not introduce transaction or visible-version concerns.
  • Performance: No hot-path or meaningful performance concern found.

Focus points: No additional user-provided review focus was present.

// under the License.

suite("test_timestamptz_default_schema_change", "p0") {
def tableName = "test_timestamptz_default_schema_change"
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.

Doris regression-test standards in AGENTS.md require hardcoding table names for ordinary single-table tests instead of using def tableName. Please inline test_timestamptz_default_schema_change in the SQL strings, or use a literal only where dynamic naming is genuinely needed.

}

sql "DROP TABLE IF EXISTS ${tableName} FORCE"
} No newline at end of file
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.

Doris regression-test standards require dropping tables before use, not after, so the failed-test environment is preserved for debugging. This suite already drops the table at the beginning; please remove the final DROP TABLE here.

@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented May 15, 2026

/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 additional blocking code issues found in this pass. I did not duplicate the two existing inline threads about regression-test table-name hardcoding and removing the final drop; those remain already-known review context.

Critical checkpoint conclusions:

  • Goal and proof: the PR targets TIMESTAMPTZ CURRENT_TIMESTAMP real-default formatting during schema change; the code passes the target type into schema-change default materialization and adds unit/regression coverage for the scenario.
  • Scope: the implementation is small and focused on default-value materialization plus formatting reuse.
  • Concurrency/lifecycle: no new shared mutable state, locks, threads, or non-intuitive lifecycle/static initialization dependency were introduced.
  • Configuration/compatibility: no new config items, protocol fields, storage formats, or rolling-upgrade compatibility paths are involved.
  • Parallel paths: both legacy ColumnDef schema-change conversion and Nereids ColumnDefinition.translateToCatalogStyleForSchemaChange() paths were updated for TIMESTAMPTZ typed formatting.
  • Conditional checks: the new type checks are limited to TIMESTAMPTZ formatting selection and match the surrounding default-value logic.
  • Tests: a FE unit test and a schema-change regression test cover the main positive case; existing inline comments already cover the remaining regression-test standards issues.
  • Observability: no new runtime operation requiring logs or metrics is introduced.
  • Transactions/persistence/data writes: no direct transaction or EditLog behavior changes were found; schema-change default materialization still flows through existing column metadata construction.
  • Performance: no hot-path regression found; formatting happens during DDL/default materialization only.

User focus: no additional user-provided review focus was present.

@Mryange Mryange changed the title [fix](sc) serialize TIMESTAMPTZ schema change defaults with offset [fix](TIMESTAMPTZ) serialize TIMESTAMPTZ schema change defaults with offset May 15, 2026
@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented May 15, 2026

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 30.43% (7/23) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 31374 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 0ae4067ffa40eadcfa97628b55417e5cbe2442d6, 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	17668	3920	3836	3836
q2	q3	10784	1361	804	804
q4	4681	480	343	343
q5	7541	2235	2102	2102
q6	232	175	138	138
q7	909	790	636	636
q8	9365	1645	1644	1644
q9	5128	4916	4908	4908
q10	6390	2047	1785	1785
q11	435	268	248	248
q12	640	421	294	294
q13	18097	3388	2738	2738
q14	264	261	237	237
q15	q16	823	766	711	711
q17	953	887	845	845
q18	6840	5736	5643	5643
q19	1180	1339	1090	1090
q20	504	415	259	259
q21	6152	2894	2798	2798
q22	458	394	315	315
Total cold run time: 99044 ms
Total hot run time: 31374 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	4831	4507	4528	4507
q2	q3	4871	5248	4603	4603
q4	2197	2209	1401	1401
q5	4705	4951	4732	4732
q6	230	184	127	127
q7	1859	1735	1595	1595
q8	2436	2104	2031	2031
q9	7864	7417	7231	7231
q10	4415	4393	3990	3990
q11	527	379	353	353
q12	711	717	515	515
q13	3058	3424	2844	2844
q14	286	271	252	252
q15	q16	683	701	614	614
q17	1268	1241	1243	1241
q18	7103	6928	7033	6928
q19	1142	1089	1108	1089
q20	2206	2207	1943	1943
q21	5349	4612	4472	4472
q22	538	460	405	405
Total cold run time: 56279 ms
Total hot run time: 50873 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

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

query5	4336	657	518	518
query6	340	220	199	199
query7	4246	601	328	328
query8	325	237	229	229
query9	8834	4057	4033	4033
query10	445	350	291	291
query11	5826	2403	2282	2282
query12	184	130	134	130
query13	1280	614	470	470
query14	6186	5298	5012	5012
query14_1	4363	4349	4292	4292
query15	207	203	181	181
query16	1003	469	413	413
query17	1183	742	573	573
query18	2707	473	345	345
query19	216	203	171	171
query20	148	135	128	128
query21	215	139	115	115
query22	13596	13631	13439	13439
query23	17159	16344	15999	15999
query23_1	16268	16213	16249	16213
query24	7480	1784	1307	1307
query24_1	1337	1324	1316	1316
query25	587	507	447	447
query26	1348	308	179	179
query27	2729	531	333	333
query28	4412	1943	1948	1943
query29	1030	640	540	540
query30	308	238	204	204
query31	1142	1062	947	947
query32	88	77	80	77
query33	583	370	314	314
query34	1155	1148	630	630
query35	776	780	672	672
query36	1331	1332	1154	1154
query37	156	110	98	98
query38	3198	3142	3052	3052
query39	945	939	923	923
query39_1	898	874	866	866
query40	230	152	130	130
query41	76	74	70	70
query42	115	109	117	109
query43	323	326	292	292
query44	
query45	216	201	201	201
query46	1044	1174	749	749
query47	2268	2415	2215	2215
query48	414	431	315	315
query49	650	515	428	428
query50	986	343	259	259
query51	4345	4296	4227	4227
query52	107	107	96	96
query53	259	288	216	216
query54	328	286	276	276
query55	96	93	84	84
query56	306	318	322	318
query57	1435	1405	1325	1325
query58	309	278	294	278
query59	1549	1619	1399	1399
query60	336	368	305	305
query61	162	160	157	157
query62	669	636	569	569
query63	244	203	229	203
query64	2347	838	635	635
query65	
query66	1667	475	353	353
query67	29888	29902	29812	29812
query68	
query69	467	354	310	310
query70	1010	1022	985	985
query71	308	277	266	266
query72	2997	2673	2414	2414
query73	824	760	432	432
query74	5058	4882	4745	4745
query75	2649	2624	2270	2270
query76	2334	1120	758	758
query77	392	417	333	333
query78	12071	12031	11675	11675
query79	1427	1046	733	733
query80	847	542	484	484
query81	490	277	248	248
query82	1387	158	124	124
query83	355	281	257	257
query84	257	146	108	108
query85	930	540	462	462
query86	448	336	316	316
query87	3408	3346	3206	3206
query88	3478	2641	2605	2605
query89	447	388	338	338
query90	1788	180	183	180
query91	181	167	142	142
query92	83	78	85	78
query93	1542	1399	825	825
query94	627	346	301	301
query95	668	382	442	382
query96	1018	796	359	359
query97	2707	2697	2579	2579
query98	236	235	227	227
query99	1121	1111	989	989
Total cold run time: 253316 ms
Total hot run time: 169649 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 16.07% (9/56) 🎉
Increment coverage report
Complete coverage report

@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented May 15, 2026

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 30587 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 54d069a28d09f7ca8635048531a801044ffc97a7, 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	17701	3860	3832	3832
q2	q3	10797	1424	827	827
q4	4682	482	345	345
q5	7555	2230	2147	2147
q6	250	173	136	136
q7	923	767	629	629
q8	9339	1769	1502	1502
q9	6597	4885	4883	4883
q10	6432	2120	1750	1750
q11	428	273	239	239
q12	690	422	293	293
q13	18227	3367	2772	2772
q14	265	252	235	235
q15	q16	814	759	712	712
q17	1015	881	905	881
q18	6731	5668	5420	5420
q19	1264	1259	1039	1039
q20	510	416	263	263
q21	5816	2591	2388	2388
q22	425	364	294	294
Total cold run time: 100461 ms
Total hot run time: 30587 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	4178	4196	4068	4068
q2	q3	4452	4900	4245	4245
q4	2102	2190	1405	1405
q5	4354	4276	4303	4276
q6	226	175	130	130
q7	2057	1867	1698	1698
q8	2517	2156	2030	2030
q9	7801	7650	7772	7650
q10	4505	4504	4023	4023
q11	584	405	488	405
q12	740	729	517	517
q13	3339	3537	3013	3013
q14	293	310	276	276
q15	q16	709	734	660	660
q17	1361	1311	1307	1307
q18	7872	7298	6961	6961
q19	1126	1101	1089	1089
q20	2186	2201	1923	1923
q21	5320	4597	4494	4494
q22	510	475	404	404
Total cold run time: 56232 ms
Total hot run time: 50574 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 169226 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 54d069a28d09f7ca8635048531a801044ffc97a7, data reload: false

query5	4320	653	504	504
query6	338	220	199	199
query7	4260	573	295	295
query8	322	230	219	219
query9	8794	3956	3964	3956
query10	475	353	310	310
query11	5783	2370	2204	2204
query12	188	133	135	133
query13	1291	625	448	448
query14	5946	5328	5032	5032
query14_1	4327	4327	4328	4327
query15	212	206	183	183
query16	1029	409	421	409
query17	1154	749	618	618
query18	2748	490	359	359
query19	224	213	174	174
query20	140	138	132	132
query21	217	146	121	121
query22	13536	13462	13388	13388
query23	17106	16339	15981	15981
query23_1	16094	16153	16139	16139
query24	7404	1762	1314	1314
query24_1	1312	1308	1299	1299
query25	578	502	449	449
query26	1180	324	174	174
query27	2694	588	344	344
query28	4448	1937	1924	1924
query29	1005	641	522	522
query30	310	241	202	202
query31	1111	1064	933	933
query32	96	76	76	76
query33	554	366	298	298
query34	1176	1114	645	645
query35	766	781	721	721
query36	1296	1292	1146	1146
query37	150	106	91	91
query38	3193	3126	3046	3046
query39	924	916	892	892
query39_1	874	875	890	875
query40	227	147	123	123
query41	65	63	62	62
query42	108	108	108	108
query43	325	323	278	278
query44	
query45	211	194	195	194
query46	1030	1178	709	709
query47	2318	2310	2238	2238
query48	402	410	321	321
query49	634	486	387	387
query50	1016	353	251	251
query51	4302	4313	4288	4288
query52	107	108	96	96
query53	257	279	210	210
query54	330	277	252	252
query55	99	97	85	85
query56	318	330	312	312
query57	1450	1446	1342	1342
query58	302	262	278	262
query59	1583	1642	1476	1476
query60	325	328	311	311
query61	158	160	156	156
query62	676	633	572	572
query63	246	204	202	202
query64	2186	782	613	613
query65	
query66	2411	482	358	358
query67	30044	29957	29824	29824
query68	
query69	451	344	340	340
query70	1011	977	993	977
query71	312	280	267	267
query72	2984	2684	2427	2427
query73	844	801	423	423
query74	5022	4861	4702	4702
query75	2655	2589	2250	2250
query76	2298	1128	783	783
query77	412	401	328	328
query78	12073	12071	11590	11590
query79	1457	1028	742	742
query80	1310	541	448	448
query81	523	280	237	237
query82	1011	161	119	119
query83	321	279	240	240
query84	253	142	114	114
query85	901	554	451	451
query86	458	369	316	316
query87	3398	3408	3203	3203
query88	3485	2643	2604	2604
query89	444	381	336	336
query90	1903	173	181	173
query91	176	166	139	139
query92	79	79	75	75
query93	1639	1478	898	898
query94	715	353	303	303
query95	704	367	341	341
query96	1080	785	353	353
query97	2688	2713	2551	2551
query98	234	235	230	230
query99	1136	1104	984	984
Total cold run time: 253630 ms
Total hot run time: 169226 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 29.63% (8/27) 🎉
Increment coverage report
Complete coverage report

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.

2 participants