Skip to content

[fix](variant) preserve subcolumns after row-store partial update - #62067

Merged
eldenmoon merged 1 commit into
apache:masterfrom
eldenmoon:fix-partial-rowstore-var
Apr 3, 2026
Merged

[fix](variant) preserve subcolumns after row-store partial update#62067
eldenmoon merged 1 commit into
apache:masterfrom
eldenmoon:fix-partial-rowstore-var

Conversation

@eldenmoon

@eldenmoon eldenmoon commented Apr 2, 2026

Copy link
Copy Markdown
Member

need to materialize variant after reading from row store when partial update

Copilot AI review requested due to automatic review settings April 2, 2026 14:36
@Thearas

Thearas commented Apr 2, 2026

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?

@eldenmoon

Copy link
Copy Markdown
Member Author

run buildall

Copilot AI left a comment

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.

Pull request overview

Adds a regression test and BE write-path changes to ensure VARIANT subcolumns are preserved/materialized correctly after row-store partial updates.

Changes:

  • Add a regression scenario that updates a non-VARIANT column and verifies VARIANT subfields remain readable and unchanged.
  • Materialize VARIANT columns after filling missing columns during partial-update writes (both SegmentWriter and VerticalSegmentWriter).

Reviewed changes

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

File Description
regression-test/suites/variant_p0/delete_update.groovy Adds a regression case for VARIANT subcolumn preservation across partial updates in row-store tables.
be/src/storage/segment/vertical_segment_writer.cpp Materializes VARIANT columns in the partial-update append path before serializing to row-store.
be/src/storage/segment/segment_writer.cpp Same VARIANT materialization step in the non-vertical segment writer partial-update append path.

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

Comment on lines +111 to +114
def wholeVariant = sql """select cast(event_property_variant as string)
from ${partialUpdateVariantTable}
where event_id = 1"""
assertEquals('{"base_id":"100000000009523363","other_key":"abc"}', wholeVariant[0][0])

Copilot AI Apr 2, 2026

Copy link

Choose a reason for hiding this comment

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

This assertion is potentially flaky because the string serialization of a VARIANT/JSON object may not guarantee key order or exact formatting. To make the test stable, assert on individual fields (e.g., base_id and other_key) or compare a canonicalized representation rather than strict string equality of the whole object.

Suggested change
def wholeVariant = sql """select cast(event_property_variant as string)
from ${partialUpdateVariantTable}
where event_id = 1"""
assertEquals('{"base_id":"100000000009523363","other_key":"abc"}', wholeVariant[0][0])
def wholeVariant = sql """select cast(event_property_variant['base_id'] as string),
cast(event_property_variant['other_key'] as string)
from ${partialUpdateVariantTable}
where event_id = 1"""
assertEquals("100000000009523363", wholeVariant[0][0])
assertEquals("abc", wholeVariant[0][1])

Copilot uses AI. Check for mistakes.
from ${partialUpdateVariantTable}
where event_id = 1"""
assertEquals("100000000009523363", beforeUpdate[0][0])

Copilot AI Apr 2, 2026

Copy link

Choose a reason for hiding this comment

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

This test intends to validate behavior after a partial update, but it doesn't explicitly enable partial updates before running the UPDATE (the suite enables enable_unique_key_partial_update later for a different section). Consider setting enable_unique_key_partial_update=true (and syncing) before this UPDATE, so the regression reliably exercises the specific code path this PR changes.

Suggested change
sql "set enable_unique_key_partial_update=true;"
sql "sync"

Copilot uses AI. Check for mistakes.
Comment thread be/src/storage/segment/vertical_segment_writer.cpp
@eldenmoon
eldenmoon force-pushed the fix-partial-rowstore-var branch from 1f48122 to cbbda43 Compare April 2, 2026 14:49
@eldenmoon

Copy link
Copy Markdown
Member Author

run buildall

@doris-robot

Copy link
Copy Markdown
TPC-H: Total hot run time: 29157 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit cbbda4390d2d2e286301409b169f62f750f05482, 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	17619	3677	3653	3653
q2	q3	10703	863	594	594
q4	4675	456	363	363
q5	7436	1344	1144	1144
q6	193	163	136	136
q7	905	931	768	768
q8	9480	1407	1333	1333
q9	5567	5357	5305	5305
q10	6303	2023	1772	1772
q11	473	278	284	278
q12	858	684	512	512
q13	18051	2780	2159	2159
q14	283	279	256	256
q15	q16	891	878	778	778
q17	1073	1107	758	758
q18	6413	5687	5482	5482
q19	1204	1252	1095	1095
q20	591	529	400	400
q21	5371	2447	2031	2031
q22	506	422	340	340
Total cold run time: 98595 ms
Total hot run time: 29157 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	4553	4462	4324	4324
q2	q3	4596	4747	4170	4170
q4	2341	2062	1352	1352
q5	4854	5065	5273	5065
q6	199	172	137	137
q7	2115	1751	1598	1598
q8	3348	3127	3020	3020
q9	8540	8240	8205	8205
q10	4478	4440	4237	4237
q11	591	431	426	426
q12	808	731	482	482
q13	3049	3179	2395	2395
q14	304	301	277	277
q15	q16	750	774	674	674
q17	1381	1265	1249	1249
q18	7853	7054	7006	7006
q19	1140	1120	1171	1120
q20	2259	2222	1957	1957
q21	5974	5243	4759	4759
q22	550	502	446	446
Total cold run time: 59683 ms
Total hot run time: 52899 ms

@doris-robot

Copy link
Copy Markdown
TPC-DS: Total hot run time: 180841 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 cbbda4390d2d2e286301409b169f62f750f05482, data reload: false

query5	4344	676	518	518
query6	355	226	206	206
query7	4226	535	357	357
query8	333	242	217	217
query9	8742	3913	3920	3913
query10	469	388	331	331
query11	6667	5511	5196	5196
query12	196	135	130	130
query13	1285	628	457	457
query14	5797	5216	4825	4825
query14_1	4187	4145	4126	4126
query15	215	205	182	182
query16	1015	473	431	431
query17	1166	735	617	617
query18	2712	473	363	363
query19	242	218	183	183
query20	146	135	129	129
query21	226	152	120	120
query22	14043	15038	14957	14957
query23	18027	17458	17165	17165
query23_1	16766	16759	16790	16759
query24	7668	1719	1346	1346
query24_1	1388	1359	1324	1324
query25	569	497	442	442
query26	1267	298	177	177
query27	2680	643	373	373
query28	4429	1892	1914	1892
query29	940	685	540	540
query30	297	233	195	195
query31	1092	1019	943	943
query32	84	68	71	68
query33	524	352	284	284
query34	1192	1198	661	661
query35	742	776	664	664
query36	1233	1184	1069	1069
query37	154	99	84	84
query38	3111	3019	3017	3017
query39	926	889	838	838
query39_1	835	828	832	828
query40	235	156	137	137
query41	61	59	57	57
query42	270	271	271	271
query43	315	320	277	277
query44	
query45	203	196	186	186
query46	1140	1216	786	786
query47	2322	2308	2185	2185
query48	403	411	306	306
query49	639	541	431	431
query50	708	298	212	212
query51	4356	4392	4223	4223
query52	281	278	272	272
query53	327	355	275	275
query54	327	290	298	290
query55	99	94	89	89
query56	331	333	322	322
query57	1766	1664	1569	1569
query58	295	277	273	273
query59	2886	3003	2716	2716
query60	329	334	317	317
query61	156	145	151	145
query62	706	625	569	569
query63	314	274	268	268
query64	5258	1440	1051	1051
query65	
query66	1398	460	382	382
query67	24344	24222	24302	24222
query68	
query69	473	345	329	329
query70	1055	1012	985	985
query71	384	336	326	326
query72	3142	2653	2543	2543
query73	800	752	442	442
query74	9840	9727	9569	9569
query75	3546	3340	2986	2986
query76	2308	1153	767	767
query77	400	423	347	347
query78	11207	11340	10721	10721
query79	1554	1090	824	824
query80	1365	733	671	671
query81	493	279	233	233
query82	1303	155	119	119
query83	342	286	260	260
query84	254	144	119	119
query85	919	502	461	461
query86	436	338	328	328
query87	3281	3200	3056	3056
query88	3606	2734	2706	2706
query89	481	406	377	377
query90	1983	179	172	172
query91	177	162	138	138
query92	77	77	72	72
query93	920	879	499	499
query94	647	341	304	304
query95	637	440	334	334
query96	990	802	347	347
query97	2664	2663	2542	2542
query98	235	228	217	217
query99	1073	1057	968	968
Total cold run time: 259603 ms
Total hot run time: 180841 ms

@doris-robot

Copy link
Copy Markdown

BE UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.94% (20057/37885)
Line Coverage 36.54% (188370/515496)
Region Coverage 32.80% (146231/445854)
Branch Coverage 33.96% (64049/188611)

@eldenmoon

Copy link
Copy Markdown
Member Author

skip check_coverage

@csun5285 csun5285 left a comment

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.

LGTM

@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@airborne12 airborne12 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Critical bug fix — variant subcolumns were lost during row-store partial update because parse_and_materialize_variant_columns was not called after fill_missing_columns. Both segment_writer and vertical_segment_writer are consistently fixed. Regression test precisely covers the failure scenario.

@eldenmoon
eldenmoon merged commit 0adc790 into apache:master Apr 3, 2026
30 of 32 checks passed
@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Apr 3, 2026
@eldenmoon eldenmoon added usercase Important user case type label dev/3.0.x and removed approved Indicates a PR has been approved by one committer. labels Apr 3, 2026
github-actions Bot pushed a commit that referenced this pull request Apr 3, 2026
…2067)

need to materialize variant after reading from row store when partial update
github-actions Bot pushed a commit that referenced this pull request Apr 3, 2026
…2067)

need to materialize variant after reading from row store when partial update
yiguolei pushed a commit that referenced this pull request Apr 3, 2026
…l update #62067 (#62076)

Cherry-picked from #62067

Co-authored-by: lihangyu <lihangyu@selectdb.com>
yiguolei pushed a commit that referenced this pull request May 7, 2026
…l update #62067 (#62075)

Cherry-picked from #62067

---------

Co-authored-by: lihangyu <lihangyu@selectdb.com>
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.

7 participants