Skip to content

[fix](be) Disambiguate duplicate JSONPath leaf columns - #67418

Open
0AyanamiRei wants to merge 1 commit into
apache:masterfrom
0AyanamiRei:fix/doris-25136-disambiguate-jsonpath-columns
Open

[fix](be) Disambiguate duplicate JSONPath leaf columns#67418
0AyanamiRei wants to merge 1 commit into
apache:masterfrom
0AyanamiRei:fix/doris-25136-disambiguate-jsonpath-columns

Conversation

@0AyanamiRei

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: JSON table-valued function schema inference used only the final key of each jsonpath as its output column name. Distinct paths such as $.left.id and $.right.id therefore both became id and failed the existing case-insensitive duplicate-column check. Detect duplicate leaf names and derive names from their path context, while preserving the existing leaf-only names for non-conflicting paths.

Release note

JSON table-valued functions now expose path-qualified column names such as left_id and right_id when selected jsonpaths have duplicate leaf names.

Check List (For Author)

  • Test: BE unit test, regression test, and manual HTTP stream test
    • BE unit test: NewJsonReaderSchemaTest.*
    • Regression test: test_jsonpaths_duplicate_leaf with left/right controls and combined paths
    • Manual test: http_stream loaded 2 rows with left_id, right_id, and city
    • BE ASAN build, format check, and build hygiene passed
    • clang-tidy: no diagnostics in added code; the command remains non-zero on existing core/types.h NOLINT and system-header conflicts
  • Behavior changed: Yes. Conflicting JSONPath leaf names are qualified with path context.
  • Does this need documentation: No

### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: JSON table-valued function schema inference used only the final key of each jsonpath as its output column name. Distinct paths such as $.left.id and $.right.id therefore both became id and failed the existing case-insensitive duplicate-column check. Detect duplicate leaf names and derive names from their path context, while preserving the existing leaf-only names for non-conflicting paths.

### Release note

JSON table-valued functions now expose path-qualified column names such as left_id and right_id when selected jsonpaths have duplicate leaf names.

### Check List (For Author)

- Test: BE unit test, regression test, and manual HTTP stream test
    - BE unit test: NewJsonReaderSchemaTest.*
    - Regression test: test_jsonpaths_duplicate_leaf with left/right controls and combined paths
    - Manual test: http_stream loaded 2 rows with left_id, right_id, and city
    - BE ASAN build, format check, and build hygiene
- Behavior changed: Yes. Conflicting JSONPath leaf names are qualified with path context.
- Does this need documentation: No
@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?

@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 82.93% (34/41) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 62.95% (29575/46982)
Line Coverage 47.99% (310130/646210)
Region Coverage 43.60% (250585/574758)
Branch Coverage 45.11% (116560/258403)

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17559	3008	3045	3008
q2	2123	263	237	237
q3	10191	880	516	516
q4	4671	247	200	200
q5	7687	572	384	384
q6	139	118	91	91
q7	519	606	385	385
q8	9245	838	899	838
q9	3410	2371	2376	2371
q10	6512	853	735	735
q11	388	198	186	186
q12	609	263	193	193
q13	18146	1518	1156	1156
q14	158	153	140	140
q15	q16	436	395	364	364
q17	1315	884	792	792
q18	3080	2246	2251	2246
q19	1251	901	754	754
q20	377	282	200	200
q21	5623	1652	1856	1652
q22	334	265	228	228
Total cold run time: 93773 ms
Total hot run time: 16676 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3397	3336	3309	3309
q2	501	390	375	375
q3	2242	2391	2245	2245
q4	1186	1168	890	890
q5	2150	2099	2085	2085
q6	162	117	87	87
q7	1023	915	863	863
q8	1586	1397	1422	1397
q9	3121	3116	3097	3097
q10	1874	1821	1612	1612
q11	352	268	257	257
q12	446	422	343	343
q13	1484	1526	1142	1142
q14	182	178	162	162
q15	q16	395	391	358	358
q17	3552	3293	3241	3241
q18	4772	4373	4684	4373
q19	831	788	915	788
q20	1000	969	854	854
q21	3860	3131	3297	3131
q22	389	344	314	314
Total cold run time: 34505 ms
Total hot run time: 30923 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 81940 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 34b7a98d2c46c11219e8b28761dc97b97db10090, data reload: false

query5	4270	409	341	341
query6	386	158	126	126
query7	4924	428	230	230
query8	300	126	116	116
query9	8696	2894	2847	2847
query10	405	243	184	184
query11	5388	1045	913	913
query12	126	71	73	71
query13	1194	443	330	330
query14	6111	2192	2080	2080
query14_1	1965	1954	1915	1915
query15	170	121	107	107
query16	920	372	346	346
query17	802	465	372	372
query18	2328	326	239	239
query19	163	142	110	110
query20	74	68	69	68
query21	198	102	92	92
query22	5521	5333	5456	5333
query23	6746	6203	5984	5984
query23_1	6008	6214	6101	6101
query24	7279	1109	757	757
query24_1	795	780	785	780
query25	430	329	266	266
query26	1232	245	134	134
query27	2770	428	248	248
query28	4671	1505	1494	1494
query29	936	443	366	366
query30	248	153	132	132
query31	816	401	328	328
query32	129	75	74	74
query33	470	223	189	189
query34	995	848	488	488
query35	408	410	348	348
query36	573	565	533	533
query37	125	86	73	73
query38	1009	850	797	797
query39	507	496	474	474
query39_1	462	450	445	445
query40	204	95	81	81
query41	59	57	57	57
query42	76	111	71	71
query43	241	242	209	209
query44	1021	538	544	538
query45	112	102	100	100
query46	774	855	556	556
query47	753	752	723	723
query48	297	283	239	239
query49	538	238	186	186
query50	744	248	194	194
query51	8062	8093	8157	8093
query52	65	72	59	59
query53	191	196	146	146
query54	234	192	158	158
query55	69	70	54	54
query56	278	158	154	154
query57	716	660	627	627
query58	214	159	164	159
query59	1200	1218	1102	1102
query60	262	188	188	188
query61	119	131	115	115
query62	352	200	189	189
query63	173	141	139	139
query64	2734	685	638	638
query65	1573	1556	1585	1556
query66	1864	272	227	227
query67	9785	9731	9566	9566
query68	3019	1213	757	757
query69	343	217	198	198
query70	673	600	611	600
query71	259	179	156	156
query72	2320	1706	1550	1550
query73	638	591	346	346
query74	2030	1230	1165	1165
query75	1165	1100	937	937
query76	2377	718	518	518
query77	252	266	200	200
query78	4104	3745	3179	3179
query79	2323	857	570	570
query80	1640	345	278	278
query81	489	156	129	129
query82	626	129	98	98
query83	279	216	192	192
query84	300	116	94	94
query85	795	347	308	308
query86	399	181	176	176
query87	1037	967	903	903
query88	2759	2122	2111	2111
query89	292	195	174	174
query90	1967	129	133	129
query91	133	125	102	102
query92	78	72	72	72
query93	1712	1147	678	678
query94	650	253	205	205
query95	515	326	227	227
query96	822	579	270	270
query97	1048	1060	1051	1051
query98	169	138	135	135
query99	425	344	310	310
Total cold run time: 178340 ms
Total hot run time: 81940 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 14.7 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 34b7a98d2c46c11219e8b28761dc97b97db10090, data reload: false

query1	0.01	0.00	0.01
query2	0.08	0.04	0.04
query3	0.25	0.10	0.11
query4	1.60	0.11	0.09
query5	0.17	0.16	0.16
query6	1.24	0.69	0.68
query7	0.04	0.01	0.01
query8	0.05	0.03	0.03
query9	0.29	0.21	0.22
query10	0.37	0.35	0.35
query11	0.16	0.11	0.12
query12	0.15	0.12	0.12
query13	0.31	0.31	0.31
query14	0.46	0.44	0.46
query15	0.37	0.34	0.35
query16	0.21	0.23	0.21
query17	0.70	0.70	0.75
query18	0.18	0.16	0.16
query19	1.13	1.17	1.17
query20	0.01	0.01	0.01
query21	15.45	0.16	0.11
query22	5.06	0.04	0.04
query23	16.18	0.25	0.10
query24	3.09	0.33	0.26
query25	0.10	0.04	0.04
query26	0.73	0.17	0.13
query27	0.04	0.03	0.03
query28	3.61	0.60	0.30
query29	12.44	3.16	2.56
query30	0.25	0.11	0.13
query31	2.75	0.38	0.17
query32	3.52	0.32	0.25
query33	1.40	1.43	1.38
query34	15.32	2.15	1.77
query35	1.78	1.75	1.71
query36	0.46	0.30	0.28
query37	0.06	0.04	0.03
query38	0.05	0.03	0.03
query39	0.03	0.02	0.02
query40	0.11	0.08	0.08
query41	0.08	0.02	0.03
query42	0.03	0.02	0.02
query43	0.04	0.03	0.02
Total cold run time: 90.36 s
Total hot run time: 14.7 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 90.24% (37/41) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.02% (34594/45505)
Line Coverage 61.04% (389970/638839)
Region Coverage 57.11% (326998/572567)
Branch Coverage 57.97% (149376/257664)

@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 82.93% (34/41) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 62.95% (29578/46985)
Line Coverage 47.99% (310148/646214)
Region Coverage 43.58% (250476/574727)
Branch Coverage 45.10% (116549/258395)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 90.24% (37/41) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.02% (34596/45507)
Line Coverage 61.05% (389983/638839)
Region Coverage 57.11% (326959/572535)
Branch Coverage 57.97% (149368/257656)

1 similar comment
@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 90.24% (37/41) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.02% (34596/45507)
Line Coverage 61.05% (389983/638839)
Region Coverage 57.11% (326959/572535)
Branch Coverage 57.97% (149368/257656)

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17600	3146	3118	3118
q2	2126	286	266	266
q3	10189	881	536	536
q4	4680	256	211	211
q5	7657	596	408	408
q6	138	116	94	94
q7	546	518	396	396
q8	9266	950	944	944
q9	3446	2394	2362	2362
q10	6522	860	726	726
q11	400	204	187	187
q12	622	265	206	206
q13	18123	1538	1163	1163
q14	164	157	145	145
q15	q16	458	400	378	378
q17	1413	850	744	744
q18	3116	2269	2245	2245
q19	1275	853	773	773
q20	396	289	204	204
q21	5649	1851	1937	1851
q22	343	271	233	233
Total cold run time: 94129 ms
Total hot run time: 17190 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3511	3444	3397	3397
q2	523	418	400	400
q3	2224	2276	2202	2202
q4	1192	1165	889	889
q5	2174	2100	2138	2100
q6	177	125	88	88
q7	1053	937	889	889
q8	1631	1451	1460	1451
q9	3166	3133	3118	3118
q10	1880	1769	1625	1625
q11	359	280	255	255
q12	459	432	344	344
q13	1474	1519	1168	1168
q14	175	171	159	159
q15	q16	395	411	362	362
q17	3579	3255	3240	3240
q18	4780	4437	4717	4437
q19	1008	852	859	852
q20	1026	969	825	825
q21	3897	3220	3227	3220
q22	408	357	339	339
Total cold run time: 35091 ms
Total hot run time: 31360 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 81436 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 34b7a98d2c46c11219e8b28761dc97b97db10090, data reload: false

query5	4245	402	337	337
query6	400	138	124	124
query7	4952	419	239	239
query8	304	121	114	114
query9	8708	2890	2897	2890
query10	388	215	175	175
query11	5377	1027	925	925
query12	125	73	71	71
query13	1199	452	333	333
query14	6096	2191	2099	2099
query14_1	2003	1976	1954	1954
query15	173	120	115	115
query16	905	370	356	356
query17	802	454	389	389
query18	2346	327	245	245
query19	176	140	112	112
query20	73	69	80	69
query21	208	102	87	87
query22	5298	5397	5356	5356
query23	6665	6201	5813	5813
query23_1	6135	5970	5881	5881
query24	7320	1077	787	787
query24_1	786	774	787	774
query25	439	304	266	266
query26	1234	235	129	129
query27	2779	416	260	260
query28	4670	1481	1514	1481
query29	941	454	365	365
query30	247	156	135	135
query31	844	410	329	329
query32	149	76	75	75
query33	472	227	189	189
query34	995	829	480	480
query35	424	427	336	336
query36	556	563	513	513
query37	120	82	67	67
query38	992	840	803	803
query39	500	502	465	465
query39_1	476	447	458	447
query40	206	86	74	74
query41	53	51	50	50
query42	79	72	69	69
query43	243	239	212	212
query44	1018	536	539	536
query45	107	104	101	101
query46	791	843	532	532
query47	753	763	690	690
query48	307	308	225	225
query49	537	232	188	188
query50	735	255	196	196
query51	8244	8059	8168	8059
query52	73	66	71	66
query53	201	193	146	146
query54	225	167	150	150
query55	78	57	54	54
query56	209	159	153	153
query57	771	659	642	642
query58	189	167	166	166
query59	1211	1247	1126	1126
query60	228	196	183	183
query61	145	113	113	113
query62	357	203	169	169
query63	166	136	144	136
query64	2754	734	584	584
query65	1604	1624	1547	1547
query66	1924	264	206	206
query67	10002	9564	9639	9564
query68	3043	1131	758	758
query69	361	225	198	198
query70	660	606	589	589
query71	244	180	169	169
query72	2358	1710	1550	1550
query73	655	582	345	345
query74	2011	1230	1133	1133
query75	1156	1101	946	946
query76	2380	735	562	562
query77	251	252	211	211
query78	4102	3641	3238	3238
query79	2690	787	590	590
query80	1565	320	283	283
query81	499	154	134	134
query82	952	128	98	98
query83	285	214	186	186
query84	301	111	90	90
query85	841	354	291	291
query86	401	175	173	173
query87	1027	970	886	886
query88	2799	2101	2109	2101
query89	285	191	175	175
query90	1950	122	120	120
query91	129	126	97	97
query92	78	70	61	61
query93	1590	1081	644	644
query94	640	259	215	215
query95	524	264	219	219
query96	761	563	256	256
query97	1044	1038	1003	1003
query98	168	139	133	133
query99	442	353	313	313
Total cold run time: 179337 ms
Total hot run time: 81436 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 14.7 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 34b7a98d2c46c11219e8b28761dc97b97db10090, data reload: false

query1	0.00	0.00	0.01
query2	0.07	0.03	0.04
query3	0.26	0.11	0.11
query4	1.60	0.09	0.10
query5	0.18	0.17	0.16
query6	1.24	0.70	0.68
query7	0.03	0.00	0.01
query8	0.06	0.05	0.03
query9	0.28	0.21	0.21
query10	0.35	0.36	0.34
query11	0.15	0.12	0.12
query12	0.15	0.12	0.13
query13	0.31	0.31	0.30
query14	0.46	0.44	0.46
query15	0.37	0.35	0.35
query16	0.23	0.23	0.23
query17	0.66	0.69	0.68
query18	0.19	0.16	0.16
query19	1.10	1.14	1.13
query20	0.02	0.01	0.01
query21	15.44	0.15	0.11
query22	5.10	0.04	0.04
query23	16.18	0.26	0.10
query24	3.04	0.32	0.28
query25	0.11	0.04	0.04
query26	0.73	0.17	0.12
query27	0.04	0.03	0.02
query28	3.67	0.56	0.28
query29	12.42	3.21	2.57
query30	0.25	0.11	0.12
query31	2.76	0.37	0.17
query32	3.54	0.32	0.23
query33	1.51	1.58	1.47
query34	15.41	2.23	1.76
query35	1.77	1.71	1.71
query36	0.45	0.29	0.28
query37	0.06	0.04	0.04
query38	0.05	0.03	0.03
query39	0.03	0.03	0.02
query40	0.12	0.07	0.08
query41	0.07	0.03	0.02
query42	0.03	0.02	0.03
query43	0.03	0.02	0.03
Total cold run time: 90.52 s
Total hot run time: 14.7 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 90.24% (37/41) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 75.98% (34575/45507)
Line Coverage 61.00% (389668/638839)
Region Coverage 57.05% (326616/572535)
Branch Coverage 57.94% (149278/257656)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 90.24% (37/41) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 75.96% (34566/45507)
Line Coverage 60.98% (389591/638839)
Region Coverage 57.04% (326557/572535)
Branch Coverage 57.91% (149213/257656)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 90.24% (37/41) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.13% (34646/45507)
Line Coverage 61.16% (390690/638839)
Region Coverage 57.27% (327887/572535)
Branch Coverage 58.10% (149689/257656)

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