Skip to content

[fix](fd)drop Function dependencies from join outer side - #65982

Open
englefly wants to merge 1 commit into
apache:masterfrom
englefly:fd-outer-join
Open

[fix](fd)drop Function dependencies from join outer side#65982
englefly wants to merge 1 commit into
apache:masterfrom
englefly:fd-outer-join

Conversation

@englefly

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

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

@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?

@englefly

Copy link
Copy Markdown
Contributor Author

run buildall

@englefly

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot 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.

Request changes: one P2 optimizer performance regression remains.

Critical checkpoint conclusions:

  • Goal and correctness: the patch prevents unsafe direct functional dependencies from surviving a null-extended outer-join side, and no unsafe edge is reconstructed through unique, uniform, equality, transitive, or pruning paths. However, it also drops still-valid dependencies whose determinant contains an originally non-null child slot; see the inline finding.
  • Scope and parallel paths: all 14 current join types, ASOF directionality, semi/anti/NAAJ and mark shapes were checked. The logical and physical hash-join switches agree; nested-loop recomputation blocks FD propagation. No additional path-specific issue was found.
  • Tests: the changed FdTest assertions inspect only the logical plan and use NOT NULL determinants, so they codify the safe dependency loss rather than reproduce the nullable-determinant collision. The physical reset/recomputation path is not covered.
  • Performance: the accepted issue prevents EliminateGroupByKey and EliminateOrderByKey from applying valid reductions. No other CPU, memory, or hot-path concern was found.
  • Concurrency, lifecycle, configuration, compatibility, persistence/transactions, data writes, FE-BE propagation, and observability: not involved in this change.
  • User focus: no additional focus was provided; the complete PR was reviewed.

Validation was static only. No build or test was run because the governing review prompt prohibits builds in this environment.

@github-actions github-actions Bot 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.

Corrected inline anchor for the accepted P2 finding. The complete checkpoint summary is in review 4769895466.

case NULL_AWARE_LEFT_ANTI_JOIN:
case LEFT_OUTER_JOIN:
case ASOF_LEFT_OUTER_JOIN:
builder.addFuncDepsDG(left().getLogicalProperties().getTrait());

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.

[P2] Preserve FDs with an originally non-null determinant

This drops the nullable child's whole FD graph, including edges that remain valid after null extension. In the new test, t2.id is NOT NULL and unique, so t2.id -> t2.id2: matched rows always have a non-null id, while every unmatched row contributes (id,id2)=(NULL,NULL). Those cases cannot collide, yet this arm discards the edge and makes EliminateGroupByKey retain GROUP BY t2.id,t2.id2 (and likewise prevents redundant order-key elimination).

The actual unsafe shape needs a nullable determinant, e.g. a matched (a=NULL, coalesce(a,1)=1) plus an unmatched (NULL,NULL). Please filter nullable-side edges based on whether their determinant can be all-null in an original child row, keep the current NOT NULL-key dependency, and test that nullable collision; the mirrored physical recomputation path should be covered as well.

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.

it makes sense

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17740	3517	3514	3514
q2	2028	287	185	185
q3	10458	1183	764	764
q4	4673	312	225	225
q5	7606	732	475	475
q6	181	140	109	109
q7	723	666	491	491
q8	10172	1480	1528	1480
q9	4626	3046	3042	3042
q10	6728	1175	975	975
q11	521	326	306	306
q12	739	519	424	424
q13	17934	2314	1854	1854
q14	191	183	169	169
q15	q16	549	504	457	457
q17	972	1017	1013	1013
q18	4640	3602	3488	3488
q19	2453	1287	1081	1081
q20	790	680	539	539
q21	5867	2436	2287	2287
q22	405	353	287	287
Total cold run time: 99996 ms
Total hot run time: 23165 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3953	3793	3772	3772
q2	246	266	188	188
q3	2702	2728	2518	2518
q4	1338	1342	1049	1049
q5	2650	2515	2500	2500
q6	211	154	105	105
q7	1299	1192	1066	1066
q8	1990	1720	1695	1695
q9	3680	3617	3631	3617
q10	2441	2385	2132	2132
q11	410	339	314	314
q12	583	539	401	401
q13	2251	2586	1987	1987
q14	237	214	206	206
q15	q16	500	517	477	477
q17	1228	1210	1179	1179
q18	5296	4864	4702	4702
q19	1181	1182	1174	1174
q20	1111	1122	954	954
q21	4278	3786	3708	3708
q22	510	447	427	427
Total cold run time: 38095 ms
Total hot run time: 34171 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 117085 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 22ab5594d21ff2b49579e97bf01db0fb3e4e3b1b, data reload: false

query5	4343	563	415	415
query6	485	227	205	205
query7	4834	541	315	315
query8	321	172	159	159
query9	8778	3923	3842	3842
query10	476	326	327	326
query11	5570	1353	1191	1191
query12	157	98	96	96
query13	1255	556	448	448
query14	6068	2820	2600	2600
query14_1	2363	2342	2339	2339
query15	200	156	140	140
query16	1056	543	507	507
query17	970	626	487	487
query18	2408	442	325	325
query19	215	189	158	158
query20	103	92	95	92
query21	227	147	130	130
query22	7433	7671	7278	7278
query23	9535	9095	8879	8879
query23_1	8931	8986	8952	8952
query24	7256	1397	1004	1004
query24_1	1007	1046	985	985
query25	560	420	374	374
query26	1289	357	204	204
query27	2659	593	365	365
query28	4385	2155	2135	2135
query29	1068	592	487	487
query30	306	235	199	199
query31	906	654	698	654
query32	109	66	76	66
query33	597	303	260	260
query34	1163	1156	669	669
query35	539	574	452	452
query36	1035	1062	1044	1044
query37	164	104	90	90
query38	1273	1027	985	985
query39	633	610	612	610
query39_1	588	584	591	584
query40	290	162	149	149
query41	67	66	65	65
query42	92	91	93	91
query43	292	300	256	256
query44	1326	793	784	784
query45	130	132	123	123
query46	1048	1135	677	677
query47	1471	1390	1349	1349
query48	431	414	291	291
query49	574	316	244	244
query50	1033	421	323	323
query51	10916	10975	11466	10975
query52	85	86	75	75
query53	234	268	201	201
query54	274	233	205	205
query55	73	70	66	66
query56	328	283	282	282
query57	898	863	764	764
query58	283	254	243	243
query59	1294	1332	1260	1260
query60	296	251	241	241
query61	153	142	147	142
query62	399	290	275	275
query63	235	191	188	188
query64	2756	908	726	726
query65	2124	2058	2041	2041
query66	1835	400	321	321
query67	16205	15964	15959	15959
query68	3141	1453	925	925
query69	408	301	276	276
query70	1132	1019	1021	1019
query71	406	335	327	327
query72	2908	2517	2295	2295
query73	804	786	469	469
query74	1696	1521	1414	1414
query75	1567	1470	1310	1310
query76	2349	978	733	733
query77	320	335	254	254
query78	6294	5742	5465	5465
query79	2688	1054	774	774
query80	2089	515	474	474
query81	497	255	234	234
query82	612	141	109	109
query83	368	321	293	293
query84	322	159	129	129
query85	959	575	528	528
query86	430	302	301	301
query87	1145	1109	1034	1034
query88	3783	2919	2924	2919
query89	404	302	269	269
query90	1925	187	187	187
query91	205	182	168	168
query92	61	64	57	57
query93	1771	1498	963	963
query94	748	357	343	343
query95	742	563	438	438
query96	970	819	367	367
query97	1357	1309	1249	1249
query98	210	176	169	169
query99	602	560	508	508
Total cold run time: 208877 ms
Total hot run time: 117085 ms

@hello-stephen

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

query1	0.00	0.00	0.00
query2	0.09	0.04	0.04
query3	0.25	0.13	0.12
query4	1.60	0.12	0.12
query5	0.18	0.17	0.17
query6	1.19	0.98	0.99
query7	0.04	0.01	0.00
query8	0.05	0.03	0.04
query9	0.32	0.25	0.26
query10	0.43	0.45	0.43
query11	0.19	0.11	0.13
query12	0.16	0.12	0.12
query13	0.37	0.39	0.39
query14	0.59	0.61	0.61
query15	0.47	0.44	0.44
query16	0.26	0.25	0.25
query17	0.93	0.92	0.93
query18	0.24	0.22	0.23
query19	1.51	1.52	1.47
query20	0.01	0.02	0.01
query21	15.43	0.23	0.16
query22	4.85	0.05	0.05
query23	16.14	0.31	0.13
query24	2.94	0.44	0.30
query25	0.12	0.05	0.04
query26	0.73	0.19	0.15
query27	0.05	0.03	0.03
query28	3.54	0.85	0.46
query29	12.60	4.29	3.42
query30	0.27	0.14	0.16
query31	2.76	0.49	0.21
query32	3.35	0.38	0.29
query33	1.71	1.73	1.69
query34	15.30	2.78	2.18
query35	2.13	2.11	2.09
query36	0.49	0.34	0.33
query37	0.07	0.06	0.05
query38	0.05	0.03	0.04
query39	0.03	0.03	0.03
query40	0.15	0.12	0.10
query41	0.08	0.04	0.03
query42	0.04	0.03	0.03
query43	0.04	0.03	0.04
Total cold run time: 91.75 s
Total hot run time: 18.65 s

@github-actions

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 Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/4.0.x dev/4.1.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants