Skip to content

[fix](parquet) Fill columns absent from the physical parquet schema - #66850

Open
liutang123 wants to merge 1 commit into
apache:masterfrom
liutang123:fix-hudi-parquet-master
Open

[fix](parquet) Fill columns absent from the physical parquet schema#66850
liutang123 wants to merge 1 commit into
apache:masterfrom
liutang123:fix-hudi-parquet-master

Conversation

@liutang123

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

A table-format reader builds its schema-change tree from FE-supplied schema info (history_schema_info, field-id mapping), so it can map a table column to a file column that is not present in this file's physical parquet schema — for example a column added by schema change whose default was never materialized into the older data files.

Such a column was neither read nor filled: _init_read_columns walks the file schema in physical order, so the column was silently dropped, and because children_column_exists() reported it as present it was never classified as fill-missing either. It then surfaced downstream as a 0-row column, tripping the filter.size() == offsets.size() check in filter_block_internal.

Detect this case in _do_init_reader by checking the mapped file column against the physical schema, and demote the column to a missing column so it is filled with its default/null values.

Stack:

F column_string.cpp:349] Check failed: filter.size() == offsets.size() (8160 vs. 0)
    doris::ColumnStr<>::filter()
    doris::ColumnNullable::filter()
    doris::Block::filter_block_internal()
    doris::RowGroupReader::next_batch()
    doris::ParquetReader::get_next_block()
    doris::HudiReader::get_next_block_inner()
    doris::FileScanner::_get_block_wrapped()
    ...

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

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

A table-format reader builds its schema-change tree from FE-supplied
schema info (history_schema_info, field-id mapping), so it can map a
table column to a file column that is not present in this file's
physical parquet schema — for example a column added by schema change
whose default was never materialized into the older data files.

Such a column was neither read nor filled: _init_read_columns walks the
file schema in physical order, so the column was silently dropped, and
because children_column_exists() reported it as present it was never
classified as fill-missing either. It then surfaced downstream as a
0-row column, tripping the filter.size() == offsets.size() check in
filter_block_internal.

Detect this case in _do_init_reader by checking the mapped file column
against the physical schema, and demote the column to a missing column
so it is filled with its default/null values.
@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?

@liutang123

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 16851 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 8e2ca97c013643e3adfc825c5a9d758a8e2be865, 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	17567	2995	2970	2970
q2	q3	10857	874	492	492
q4	4684	249	201	201
q5	7679	590	395	395
q6	136	115	91	91
q7	530	492	391	391
q8	9262	863	920	863
q9	3534	2409	2324	2324
q10	6516	840	741	741
q11	477	260	243	243
q12	704	398	333	333
q13	17870	1546	1156	1156
q14	162	149	131	131
q15	q16	481	396	369	369
q17	838	795	866	795
q18	3127	2234	2248	2234
q19	1116	909	750	750
q20	698	530	445	445
q21	5261	1705	1871	1705
q22	323	263	222	222
Total cold run time: 91822 ms
Total hot run time: 16851 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	3345	3277	3270	3270
q2	q3	2182	2352	2177	2177
q4	1183	1158	880	880
q5	2154	2112	2126	2112
q6	165	119	89	89
q7	1068	897	852	852
q8	1586	1413	1406	1406
q9	3105	3117	3080	3080
q10	1825	1787	1599	1599
q11	353	270	257	257
q12	450	422	341	341
q13	1489	1525	1178	1178
q14	164	178	173	173
q15	q16	388	395	357	357
q17	1039	1029	1011	1011
q18	4976	4381	4754	4381
q19	876	849	824	824
q20	962	947	819	819
q21	3467	3217	3233	3217
q22	395	353	332	332
Total cold run time: 31172 ms
Total hot run time: 28355 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 80393 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 8e2ca97c013643e3adfc825c5a9d758a8e2be865, data reload: false

query5	4267	414	334	334
query6	547	162	148	148
query7	4874	425	267	267
query8	350	130	118	118
query9	8712	2906	2917	2906
query10	405	252	208	208
query11	5397	1027	900	900
query12	131	72	73	72
query13	1198	459	325	325
query14	6148	2203	2092	2092
query14_1	1957	1970	1969	1969
query15	189	123	113	113
query16	997	409	371	371
query17	847	448	371	371
query18	2377	318	222	222
query19	184	133	114	114
query20	67	67	67	67
query21	227	113	98	98
query22	5376	5301	5366	5301
query23	6546	6004	5907	5907
query23_1	5974	6076	6103	6076
query24	7391	1089	763	763
query24_1	791	790	815	790
query25	441	284	230	230
query26	1258	263	158	158
query27	2728	444	284	284
query28	4639	1500	1489	1489
query29	958	438	347	347
query30	290	175	159	159
query31	882	422	346	346
query32	151	49	47	47
query33	475	207	168	168
query34	1164	832	498	498
query35	404	389	335	335
query36	578	554	541	541
query37	137	82	72	72
query38	1021	838	796	796
query39	497	506	456	456
query39_1	476	450	461	450
query40	245	122	112	112
query41	52	50	50	50
query42	79	76	80	76
query43	241	237	214	214
query44	
query45	117	109	99	99
query46	784	891	540	540
query47	744	748	713	713
query48	306	302	228	228
query49	554	237	183	183
query50	830	326	260	260
query51	7975	7839	7992	7839
query52	75	79	65	65
query53	202	223	162	162
query54	270	185	162	162
query55	98	63	61	61
query56	258	224	216	216
query57	710	682	692	682
query58	259	219	209	209
query59	1211	1235	1084	1084
query60	307	215	222	215
query61	135	139	138	138
query62	560	203	180	180
query63	187	158	161	158
query64	2931	789	674	674
query65	
query66	1944	334	344	334
query67	10179	9876	9794	9794
query68	
query69	430	221	196	196
query70	659	617	632	617
query71	307	256	246	246
query72	2710	1980	1660	1660
query73	759	584	344	344
query74	1990	1261	1193	1193
query75	1298	1143	1054	1054
query76	2364	725	541	541
query77	270	251	211	211
query78	3917	3603	3200	3200
query79	3532	766	593	593
query80	1723	412	361	361
query81	546	202	185	185
query82	1497	139	104	104
query83	338	254	234	234
query84	
query85	1018	452	372	372
query86	637	167	175	167
query87	1032	948	892	892
query88	4489	2161	2102	2102
query89	382	226	204	204
query90	2114	148	145	145
query91	154	136	121	121
query92	111	44	46	44
query93	2996	1116	748	748
query94	1177	223	236	223
query95	706	354	423	354
query96	773	606	264	264
query97	1071	1042	1024	1024
query98	194	135	129	129
query99	514	333	306	306
Total cold run time: 181459 ms
Total hot run time: 80393 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 81181 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 8e2ca97c013643e3adfc825c5a9d758a8e2be865, data reload: false

query5	4294	434	347	347
query6	426	171	162	162
query7	4805	473	264	264
query8	296	130	121	121
query9	8687	2998	3013	2998
query10	387	265	224	224
query11	5360	1035	909	909
query12	122	73	78	73
query13	1201	428	306	306
query14	6010	2254	2143	2143
query14_1	2016	2016	1999	1999
query15	172	119	109	109
query16	941	382	364	364
query17	806	460	371	371
query18	2337	353	265	265
query19	173	145	110	110
query20	71	69	68	68
query21	210	114	107	107
query22	5259	5264	5271	5264
query23	6677	6231	5950	5950
query23_1	6098	6005	6172	6005
query24	7226	1094	777	777
query24_1	746	787	807	787
query25	401	285	237	237
query26	1255	262	169	169
query27	2719	448	295	295
query28	4610	1524	1495	1495
query29	913	434	346	346
query30	279	189	155	155
query31	871	424	347	347
query32	106	54	48	48
query33	450	219	171	171
query34	997	866	482	482
query35	397	402	333	333
query36	576	552	516	516
query37	116	80	70	70
query38	1016	845	847	845
query39	519	500	490	490
query39_1	479	501	467	467
query40	227	121	119	119
query41	54	52	52	52
query42	108	78	81	78
query43	244	245	216	216
query44	
query45	114	109	97	97
query46	802	837	551	551
query47	780	770	719	719
query48	315	319	237	237
query49	546	235	197	197
query50	828	336	258	258
query51	8251	8083	8079	8079
query52	76	75	67	67
query53	208	222	161	161
query54	237	197	180	180
query55	72	59	57	57
query56	248	231	321	231
query57	697	669	668	668
query58	231	213	208	208
query59	1242	1252	1104	1104
query60	270	220	211	211
query61	133	138	133	133
query62	385	209	199	199
query63	185	163	163	163
query64	2800	768	673	673
query65	
query66	1908	323	306	306
query67	10169	10064	9782	9782
query68	
query69	373	227	201	201
query70	634	622	626	622
query71	310	258	239	239
query72	2442	1523	1671	1523
query73	657	577	361	361
query74	1849	1255	1211	1211
query75	1285	1167	1040	1040
query76	2362	731	564	564
query77	261	286	224	224
query78	3972	3632	3273	3273
query79	3523	753	586	586
query80	1578	397	352	352
query81	517	203	179	179
query82	635	141	105	105
query83	318	255	237	237
query84	
query85	864	443	380	380
query86	485	175	168	168
query87	1002	975	900	900
query88	4492	2151	2144	2144
query89	288	233	210	210
query90	2101	148	147	147
query91	158	143	123	123
query92	67	46	44	44
query93	3007	1158	755	755
query94	641	270	226	226
query95	632	375	408	375
query96	849	630	291	291
query97	1079	1073	1033	1033
query98	179	136	130	130
query99	439	350	308	308
Total cold run time: 177548 ms
Total hot run time: 81181 ms

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 44.44% (4/9) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 62.08% (28856/46481)
Line Coverage 47.10% (301509/640192)
Region Coverage 42.83% (243801/569236)
Branch Coverage 44.40% (113419/255463)

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