You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "starocean999 (via GitHub)" <gi...@apache.org> on 2026/01/14 08:21:56 UTC

[PR] [refactor](rec_cte)recursive-CTE refactor [doris]

starocean999 opened a new pull request, #59872:
URL: https://github.com/apache/doris/pull/59872

   Refactor recursive-CTE fe part.
   
   Related PR: https://github.com/apache/doris/pull/58916
   
   **Summary**
   
   - **Description:** Replace the legacy RecursiveCTE model with a clearer RecursiveUnion model (anchor / producer / work-table reference), update planner/physical nodes, runtime Thrift wiring, stats, visitors and tests to match.
   - **Motivation:** Separate anchor (initial rows) and producer (recursive body) responsibilities; make work-table explicit; deliver BE control/reset info via Thrift.
   
   **High-Level Design Changes**
   
   - **Model Change:** Introduced RecursiveUnion concept (anchor / producer / work-table reference) replacing old RecursiveCte/RecursiveCteScan model.
   - **Stats:** New estimation flow for recursive nodes and an expansion ratio to estimate recursion growth.
   - **Types:** Added [equalsForRecursiveCte](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) hooks for type-equality checks used during recursive compatibility/coercion.
   
   **Logical / Physical Nodes Added**
   
   - **LogicalRecursiveUnion:** [LogicalRecursiveUnion.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) — new main logical node representing recursive union.
   - **LogicalRecursiveUnionAnchor:** [LogicalRecursiveUnionAnchor.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) — anchor sentinel (initial side).
   - **LogicalRecursiveUnionProducer:** [LogicalRecursiveUnionProducer.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) — producer sentinel (recursive side).
   - **LogicalWorkTableReference:** [LogicalWorkTableReference.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) — logical ref to recursive work table.
   - **Physical counterparts:**
     - PhysicalRecursiveUnion: [PhysicalRecursiveUnion.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
     - PhysicalRecursiveUnionAnchor: [PhysicalRecursiveUnionAnchor.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
     - PhysicalRecursiveUnionProducer: [PhysicalRecursiveUnionProducer.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
     - PhysicalWorkTableReference: [PhysicalWorkTableReference.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
   
   **Removed / Renamed**
   
   - **Removed old scan/job classes:** `LogicalRecursiveCteScan`, `PhysicalRecursiveCteScan`, `UnassignedRecursiveCteScanJob` were deleted.
     - Deleted: fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalRecursiveCteScan.java
     - Deleted: fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalRecursiveCteScan.java
     - Deleted: fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/distribute/worker/job/UnassignedRecursiveCteScanJob.java
   
   **Visitor / Copier / Planner Updates**
   
   - **PlanVisitor / RelationVisitor:** Added visitors for the new nodes and removed/renamed the old recursive-cte visit methods.
     - Files: [PlanVisitor.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html), [RelationVisitor.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
   - **Deep copy:** [LogicalPlanDeepCopier](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) support for new RecursiveUnion nodes.
     - File: [LogicalPlanDeepCopier.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
   
   **Rewrite / Optimization Rules**
   
   - **CTEInline / ColumnPruning / AdjustNullable:** Adjusted to work with new node types; legacy per-recursive-node logic removed or migrated.
     - Files:
       - [CTEInline.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
       - [ColumnPruning.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
       - [AdjustNullable.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
   
   **Distribution / Job Builder**
   
   - **UnassignedJobBuilder:** Removed special-case for recursive-CTE scanning; new sentinel nodes drive shuffle/assignment decisions.
     - File: [UnassignedJobBuilder.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
   
   **Statistics / Cost**
   
   - **StatsCalculator:** Reworked to support new nodes and added [RECURSIVE_CTE_EXPAND_RATION](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) to estimate recursion expansion; anchor stores producer stats by [CTEId](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html).
     - File: [StatsCalculator.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
   
   **Type Equality**
   
   - **DataType equality hooks:** Added [equalsForRecursiveCte](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) and specific implementations for complex types to relax/adjust equality semantics in recursive contexts.
     - Files: [DataType.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html), [StructType.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html), [VariantType.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
   
   **Analyzer / CTE handling**
   
   - **LogicalCTE:** field renamed to [isRecursive](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) and usage updated.
     - File: [LogicalCTE.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
   - **LogicalSubQueryAlias:** enhanced logic to detect recursive CTE by relation name (case handling) to differentiate analysis paths.
     - File: [LogicalSubQueryAlias.java](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] 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 <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [ ] No.
       - [ ] Yes. <!-- Add document PR link here. eg: https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "starocean999 (via GitHub)" <gi...@apache.org>.
starocean999 commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3752660858

   run buildall


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "starocean999 (via GitHub)" <gi...@apache.org>.
starocean999 merged PR #59872:
URL: https://github.com/apache/doris/pull/59872


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "starocean999 (via GitHub)" <gi...@apache.org>.
starocean999 commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3753061166

   run buildall


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3753246370

   # FE UT Coverage Report
   Increment line coverage `  66.21% (241/364)` :tada:
   [Increment coverage report](http://coverage.selectdb-in.cc/coverage/59872_7f745fddab582f6314d51bcc5a5e221dca8dd2cd/fe_increment_report/index.html)
   [Complete coverage report](http://coverage.selectdb-in.cc/coverage/59872_7f745fddab582f6314d51bcc5a5e221dca8dd2cd/fe_report/index.html)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3748374252

   
   Thank you for your contribution to Apache Doris.
   Don't know what should be done next? See [How to process your PR](https://cwiki.apache.org/confluence/display/DORIS/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?
       


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3753352609

   
   <details>
   <summary>TPC-H: <b>Total hot run time: 31750 ms</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
   Tpch sf100 test result on commit 7f745fddab582f6314d51bcc5a5e221dca8dd2cd, data reload: false
   
   ------ Round 1 ----------------------------------
   q1	17646	4194	4102	4102
   q2	2032	357	247	247
   q3	10161	1297	743	743
   q4	10218	874	318	318
   q5	7755	2125	1919	1919
   q6	249	179	150	150
   q7	949	804	659	659
   q8	9279	1459	1100	1100
   q9	5072	4774	4609	4609
   q10	6755	1826	1410	1410
   q11	508	301	292	292
   q12	690	751	597	597
   q13	17781	3864	3138	3138
   q14	293	291	289	289
   q15	594	501	513	501
   q16	715	672	652	652
   q17	658	803	521	521
   q18	6799	6394	6364	6364
   q19	1238	995	634	634
   q20	397	365	239	239
   q21	3160	2590	2311	2311
   q22	1028	1027	955	955
   Total cold run time: 103977 ms
   Total hot run time: 31750 ms
   
   ----- Round 2, with runtime_filter_mode=off -----
   q1	4129	4074	4068	4068
   q2	342	372	327	327
   q3	2108	2597	2218	2218
   q4	1330	1741	1307	1307
   q5	4139	4087	4134	4087
   q6	208	171	136	136
   q7	1873	1858	2052	1858
   q8	2688	2478	2509	2478
   q9	7273	7224	7151	7151
   q10	2537	2833	2247	2247
   q11	578	490	476	476
   q12	717	766	613	613
   q13	3554	4226	3804	3804
   q14	294	299	273	273
   q15	550	509	505	505
   q16	617	695	660	660
   q17	1248	1378	1619	1378
   q18	8093	7796	7610	7610
   q19	896	865	874	865
   q20	1950	2256	1889	1889
   q21	4943	4431	4289	4289
   q22	1089	1004	992	992
   Total cold run time: 51156 ms
   Total hot run time: 49231 ms
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "starocean999 (via GitHub)" <gi...@apache.org>.
starocean999 commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3748374700

   run buildall


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3757907581

   # FE Regression Coverage Report
   Increment line coverage `  66.48% (242/364)` :tada:
   [Increment coverage report](http://coverage.selectdb-in.cc/coverage/59872_7f745fddab582f6314d51bcc5a5e221dca8dd2cd_merge_fe/increment_report/index.html)
   [Complete coverage report](http://coverage.selectdb-in.cc/coverage/59872_7f745fddab582f6314d51bcc5a5e221dca8dd2cd_merge_fe/report/index.html)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3766268872

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3753415163

   
   <details>
   <summary>TPC-DS: <b>Total hot run time: 174446 ms</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
   TPC-DS sf100 test result on commit 7f745fddab582f6314d51bcc5a5e221dca8dd2cd, data reload: false
   
   query5	4426	620	492	492
   query6	356	250	229	229
   query7	4220	453	266	266
   query8	349	254	247	247
   query9	8723	2922	2880	2880
   query10	558	380	328	328
   query11	15312	15369	14904	14904
   query12	174	124	114	114
   query13	1278	500	404	404
   query14	6135	3017	2797	2797
   query14_1	2710	2641	2717	2641
   query15	198	190	172	172
   query16	994	497	463	463
   query17	1115	682	583	583
   query18	2454	460	353	353
   query19	222	222	229	222
   query20	118	111	113	111
   query21	213	134	114	114
   query22	3964	3943	3864	3864
   query23	15979	15738	15220	15220
   query23_1	15402	15407	15434	15407
   query24	7117	1549	1158	1158
   query24_1	1153	1159	1182	1159
   query25	538	445	408	408
   query26	1241	264	148	148
   query27	2773	436	308	308
   query28	4549	2130	2146	2130
   query29	788	535	419	419
   query30	309	239	203	203
   query31	811	627	561	561
   query32	83	75	74	74
   query33	529	357	313	313
   query34	906	873	532	532
   query35	712	754	684	684
   query36	853	916	840	840
   query37	139	95	85	85
   query38	2722	2736	2666	2666
   query39	767	744	732	732
   query39_1	709	719	705	705
   query40	223	138	120	120
   query41	68	67	64	64
   query42	106	99	100	99
   query43	452	457	459	457
   query44	1362	758	730	730
   query45	185	184	178	178
   query46	828	949	577	577
   query47	1414	1425	1271	1271
   query48	335	332	252	252
   query49	615	426	339	339
   query50	615	277	208	208
   query51	3815	3805	3752	3752
   query52	107	111	98	98
   query53	295	326	273	273
   query54	299	270	283	270
   query55	86	80	76	76
   query56	306	302	304	302
   query57	1013	1056	937	937
   query58	275	259	262	259
   query59	2166	2210	2108	2108
   query60	347	333	325	325
   query61	166	161	162	161
   query62	388	353	310	310
   query63	302	269	266	266
   query64	5048	1426	1057	1057
   query65	3840	3736	3716	3716
   query66	1456	422	313	313
   query67	15824	15704	15444	15444
   query68	2414	1081	763	763
   query69	449	355	333	333
   query70	1016	970	958	958
   query71	317	316	293	293
   query72	5417	3302	3331	3302
   query73	596	739	319	319
   query74	8704	8851	8605	8605
   query75	2761	2814	2461	2461
   query76	2280	1053	651	651
   query77	356	383	302	302
   query78	9805	9782	9205	9205
   query79	1052	900	568	568
   query80	1198	612	505	505
   query81	524	260	236	236
   query82	1342	145	107	107
   query83	366	256	241	241
   query84	264	115	98	98
   query85	995	539	467	467
   query86	358	300	322	300
   query87	2821	2932	2804	2804
   query88	3497	2598	2580	2580
   query89	391	362	327	327
   query90	1875	173	166	166
   query91	174	167	147	147
   query92	73	80	71	71
   query93	897	905	533	533
   query94	582	339	310	310
   query95	595	347	326	326
   query96	678	509	235	235
   query97	2342	2357	2300	2300
   query98	216	199	200	199
   query99	641	581	496	496
   Total cold run time: 247457 ms
   Total hot run time: 174446 ms
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3753440733

   
   <details>
   <summary>ClickBench: <b>Total hot run time: 26.66 s</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
   ClickBench test result on commit 7f745fddab582f6314d51bcc5a5e221dca8dd2cd, data reload: false
   
   query1	0.06	0.05	0.05
   query2	0.09	0.05	0.04
   query3	0.25	0.08	0.08
   query4	1.61	0.12	0.11
   query5	0.27	0.25	0.25
   query6	1.15	0.67	0.65
   query7	0.03	0.02	0.03
   query8	0.05	0.04	0.05
   query9	0.58	0.52	0.50
   query10	0.56	0.55	0.54
   query11	0.14	0.10	0.10
   query12	0.14	0.11	0.11
   query13	0.59	0.58	0.59
   query14	0.95	0.93	0.95
   query15	0.79	0.78	0.77
   query16	0.40	0.40	0.39
   query17	1.07	1.01	1.07
   query18	0.22	0.21	0.21
   query19	1.98	1.90	1.86
   query20	0.02	0.01	0.01
   query21	15.45	0.27	0.13
   query22	5.13	0.05	0.05
   query23	15.84	0.30	0.10
   query24	1.16	0.64	0.19
   query25	0.09	0.09	0.08
   query26	0.14	0.14	0.14
   query27	0.13	0.06	0.05
   query28	4.09	1.09	0.87
   query29	12.57	3.96	3.14
   query30	0.28	0.14	0.12
   query31	2.85	0.62	0.40
   query32	3.26	0.57	0.45
   query33	3.05	2.98	3.08
   query34	16.14	5.06	4.41
   query35	4.49	4.46	4.56
   query36	0.65	0.50	0.50
   query37	0.11	0.06	0.07
   query38	0.07	0.04	0.04
   query39	0.05	0.03	0.02
   query40	0.17	0.14	0.13
   query41	0.10	0.03	0.03
   query42	0.05	0.03	0.03
   query43	0.04	0.04	0.03
   Total cold run time: 96.86 s
   Total hot run time: 26.66 s
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3752784141

   
   <details>
   <summary>TPC-DS: <b>Total hot run time: 173839 ms</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
   TPC-DS sf100 test result on commit 9f75bd8d6c123e4572fe07b196b968c503667eed, data reload: false
   
   query5	4405	621	473	473
   query6	330	221	224	221
   query7	4239	455	259	259
   query8	352	267	251	251
   query9	8747	2860	2856	2856
   query10	479	389	328	328
   query11	15320	15329	14912	14912
   query12	170	121	113	113
   query13	1262	487	387	387
   query14	6237	3027	2763	2763
   query14_1	2662	2691	2667	2667
   query15	204	189	179	179
   query16	966	472	447	447
   query17	1122	692	577	577
   query18	2533	439	341	341
   query19	230	225	199	199
   query20	120	116	114	114
   query21	219	134	120	120
   query22	3912	4140	3990	3990
   query23	16083	15780	15373	15373
   query23_1	15360	15526	15593	15526
   query24	7157	1571	1160	1160
   query24_1	1181	1181	1169	1169
   query25	556	464	438	438
   query26	1267	262	155	155
   query27	2771	436	273	273
   query28	4548	2105	2110	2105
   query29	809	547	450	450
   query30	316	247	209	209
   query31	772	625	579	579
   query32	89	81	71	71
   query33	545	369	314	314
   query34	922	869	536	536
   query35	721	786	678	678
   query36	829	916	871	871
   query37	127	97	83	83
   query38	2675	2731	2595	2595
   query39	785	757	741	741
   query39_1	709	702	710	702
   query40	221	130	118	118
   query41	64	62	60	60
   query42	102	100	96	96
   query43	407	422	423	422
   query44	1319	710	733	710
   query45	184	186	177	177
   query46	816	932	563	563
   query47	1408	1441	1430	1430
   query48	321	314	244	244
   query49	599	435	332	332
   query50	616	268	213	213
   query51	3759	4137	3801	3801
   query52	103	108	98	98
   query53	288	317	273	273
   query54	285	262	264	262
   query55	80	80	78	78
   query56	304	298	292	292
   query57	1034	999	928	928
   query58	271	259	259	259
   query59	2152	2206	2051	2051
   query60	331	332	310	310
   query61	154	159	147	147
   query62	396	349	312	312
   query63	297	266	261	261
   query64	4900	1315	975	975
   query65	3794	3636	3741	3636
   query66	1420	404	322	322
   query67	15595	15524	15379	15379
   query68	2429	1061	755	755
   query69	446	362	321	321
   query70	991	972	939	939
   query71	319	306	281	281
   query72	5469	3257	3068	3068
   query73	596	744	301	301
   query74	8663	8683	8658	8658
   query75	2739	2792	2443	2443
   query76	2287	1055	651	651
   query77	349	374	300	300
   query78	9624	9750	9166	9166
   query79	2305	878	594	594
   query80	1760	559	484	484
   query81	534	259	235	235
   query82	947	143	113	113
   query83	320	263	237	237
   query84	252	114	88	88
   query85	897	493	437	437
   query86	405	300	324	300
   query87	2810	2866	2765	2765
   query88	3470	2561	2536	2536
   query89	378	347	316	316
   query90	1983	168	161	161
   query91	174	153	134	134
   query92	74	75	66	66
   query93	1087	873	531	531
   query94	653	287	278	278
   query95	573	323	376	323
   query96	632	495	223	223
   query97	2332	2389	2301	2301
   query98	205	202	196	196
   query99	594	602	502	502
   Total cold run time: 248292 ms
   Total hot run time: 173839 ms
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3752792478

   
   <details>
   <summary>ClickBench: <b>Total hot run time: 26.76 s</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
   ClickBench test result on commit 9f75bd8d6c123e4572fe07b196b968c503667eed, data reload: false
   
   query1	0.06	0.05	0.05
   query2	0.10	0.04	0.04
   query3	0.26	0.09	0.08
   query4	1.61	0.12	0.11
   query5	0.26	0.25	0.24
   query6	1.14	0.66	0.65
   query7	0.04	0.03	0.03
   query8	0.06	0.04	0.04
   query9	0.57	0.50	0.49
   query10	0.55	0.55	0.54
   query11	0.14	0.10	0.09
   query12	0.14	0.10	0.10
   query13	0.59	0.59	0.60
   query14	0.94	0.94	0.95
   query15	0.79	0.76	0.77
   query16	0.39	0.39	0.40
   query17	1.10	1.05	1.05
   query18	0.23	0.22	0.21
   query19	1.89	1.93	1.86
   query20	0.02	0.01	0.02
   query21	15.96	0.28	0.15
   query22	5.52	0.05	0.04
   query23	15.96	0.29	0.10
   query24	1.44	0.35	0.18
   query25	0.09	0.08	0.08
   query26	0.15	0.13	0.14
   query27	0.06	0.08	0.06
   query28	3.36	1.07	0.91
   query29	12.54	3.88	3.16
   query30	0.28	0.14	0.11
   query31	2.82	0.62	0.40
   query32	3.25	0.57	0.46
   query33	2.97	3.04	3.03
   query34	15.90	5.07	4.41
   query35	4.43	4.42	4.51
   query36	0.64	0.51	0.50
   query37	0.11	0.07	0.06
   query38	0.07	0.04	0.03
   query39	0.04	0.04	0.03
   query40	0.17	0.14	0.13
   query41	0.09	0.03	0.03
   query42	0.04	0.04	0.04
   query43	0.05	0.04	0.03
   Total cold run time: 96.82 s
   Total hot run time: 26.76 s
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3752828086

   # FE UT Coverage Report
   Increment line coverage `  66.21% (241/364)` :tada:
   [Increment coverage report](http://coverage.selectdb-in.cc/coverage/59872_9f75bd8d6c123e4572fe07b196b968c503667eed/fe_increment_report/index.html)
   [Complete coverage report](http://coverage.selectdb-in.cc/coverage/59872_9f75bd8d6c123e4572fe07b196b968c503667eed/fe_report/index.html)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3754232822

   # FE Regression Coverage Report
   Increment line coverage `  68.13% (248/364)` :tada:
   [Increment coverage report](http://coverage.selectdb-in.cc/coverage/59872_7f745fddab582f6314d51bcc5a5e221dca8dd2cd_merge_fe/increment_report/index.html)
   [Complete coverage report](http://coverage.selectdb-in.cc/coverage/59872_7f745fddab582f6314d51bcc5a5e221dca8dd2cd_merge_fe/report/index.html)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3752762253

   
   <details>
   <summary>TPC-H: <b>Total hot run time: 31820 ms</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
   Tpch sf100 test result on commit 9f75bd8d6c123e4572fe07b196b968c503667eed, data reload: false
   
   ------ Round 1 ----------------------------------
   q1	17596	4230	4061	4061
   q2	2128	345	259	259
   q3	10095	1249	721	721
   q4	10213	835	301	301
   q5	7501	2037	1822	1822
   q6	180	165	134	134
   q7	925	783	638	638
   q8	9267	1391	1124	1124
   q9	4877	4684	4673	4673
   q10	6758	1819	1416	1416
   q11	519	295	277	277
   q12	701	730	571	571
   q13	17790	3800	3075	3075
   q14	292	292	272	272
   q15	592	525	512	512
   q16	658	668	652	652
   q17	640	800	475	475
   q18	6568	6401	6863	6401
   q19	1098	1062	648	648
   q20	398	407	263	263
   q21	3166	2612	2473	2473
   q22	1177	1079	1052	1052
   Total cold run time: 103139 ms
   Total hot run time: 31820 ms
   
   ----- Round 2, with runtime_filter_mode=off -----
   q1	4289	4181	4217	4181
   q2	343	433	322	322
   q3	2269	2836	2486	2486
   q4	1465	1842	1434	1434
   q5	4663	4337	4406	4337
   q6	215	166	124	124
   q7	1962	1912	1742	1742
   q8	2551	2415	2312	2312
   q9	7196	7313	7183	7183
   q10	2579	2664	2295	2295
   q11	549	475	441	441
   q12	698	731	573	573
   q13	3291	3791	3094	3094
   q14	280	278	261	261
   q15	521	486	479	479
   q16	625	651	597	597
   q17	1081	1233	1299	1233
   q18	7341	7272	7123	7123
   q19	830	756	786	756
   q20	1877	1922	1816	1816
   q21	4409	4252	4001	4001
   q22	1076	1015	969	969
   Total cold run time: 50110 ms
   Total hot run time: 47759 ms
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #59872:
URL: https://github.com/apache/doris/pull/59872#discussion_r2692952919


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalWorkTableReference.java:
##########
@@ -0,0 +1,152 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.trees.plans.physical;
+
+import org.apache.doris.nereids.memo.GroupExpression;
+import org.apache.doris.nereids.properties.DataTrait;
+import org.apache.doris.nereids.properties.LogicalProperties;
+import org.apache.doris.nereids.properties.PhysicalProperties;
+import org.apache.doris.nereids.trees.expressions.CTEId;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.RelationId;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
+import org.apache.doris.nereids.util.Utils;
+import org.apache.doris.statistics.Statistics;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * PhysicalRecursiveCteScan.
+ */
+public class PhysicalWorkTableReference extends PhysicalRelation {
+    private CTEId cteId;
+    private final List<Slot> outputs;
+    private final List<String> nameParts;
+
+    public PhysicalWorkTableReference(RelationId relationId, CTEId cteId, List<Slot> outputs, List<String> nameParts,
+            Optional<GroupExpression> groupExpression, LogicalProperties logicalProperties) {
+        this(relationId, cteId, outputs, nameParts, groupExpression, logicalProperties, PhysicalProperties.ANY, null);
+    }
+
+    public PhysicalWorkTableReference(RelationId relationId, CTEId cteId, List<Slot> outputs, List<String> nameParts,
+            Optional<GroupExpression> groupExpression, LogicalProperties logicalProperties,
+            PhysicalProperties physicalProperties, Statistics statistics) {
+        super(relationId, PlanType.PHYSICAL_WORK_TABLE_REFERENCE, groupExpression, logicalProperties,
+                physicalProperties, statistics);
+        this.cteId = cteId;
+        this.outputs = Objects.requireNonNull(outputs);
+        this.nameParts = Objects.requireNonNull(nameParts);
+    }
+
+    public CTEId getCteId() {
+        return cteId;
+    }
+
+    public List<String> getNameParts() {
+        return nameParts;
+    }
+
+    public String getTableName() {
+        return nameParts.stream().map(Utils::quoteIfNeeded)
+                .reduce((left, right) -> left + "." + right).orElse("");
+    }
+
+    @Override
+    public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
+        return visitor.visitPhysicalWorkTableReference(this, context);
+    }
+
+    @Override
+    public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
+        return new PhysicalWorkTableReference(relationId, cteId, outputs, nameParts, groupExpression,
+                getLogicalProperties(),
+                physicalProperties, statistics);
+    }
+
+    @Override
+    public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
+            Optional<LogicalProperties> logicalProperties, List<Plan> children) {
+        return new PhysicalWorkTableReference(relationId, cteId, outputs, nameParts, groupExpression,
+                getLogicalProperties(),
+                physicalProperties, statistics);
+    }
+
+    @Override
+    public void computeUnique(DataTrait.Builder builder) {
+
+    }
+
+    @Override
+    public void computeUniform(DataTrait.Builder builder) {
+
+    }
+
+    @Override
+    public void computeEqualSet(DataTrait.Builder builder) {
+
+    }
+
+    @Override
+    public void computeFd(DataTrait.Builder builder) {
+
+    }
+
+    @Override
+    public PhysicalPlan withPhysicalPropertiesAndStats(PhysicalProperties physicalProperties, Statistics statistics) {
+        return new PhysicalWorkTableReference(relationId, cteId, outputs, nameParts, groupExpression,
+                getLogicalProperties(),
+                physicalProperties, statistics);
+    }
+
+    @Override
+    public List<Slot> getOutput() {
+        return outputs;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        if (!super.equals(o)) {
+            return false;
+        }
+        PhysicalWorkTableReference that = (PhysicalWorkTableReference) o;
+        return cteId.equals(that.cteId) && nameParts.equals(that.nameParts) && outputs.equals(outputs);

Review Comment:
   In the equals method, `outputs.equals(outputs)` compares outputs to itself instead of comparing to `that.outputs`. This should be `outputs.equals(that.outputs)`.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalRecursiveUnionAnchor.java:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.trees.plans.physical;
+
+import org.apache.doris.nereids.memo.GroupExpression;
+import org.apache.doris.nereids.properties.DataTrait;
+import org.apache.doris.nereids.properties.LogicalProperties;
+import org.apache.doris.nereids.properties.PhysicalProperties;
+import org.apache.doris.nereids.trees.expressions.CTEId;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
+import org.apache.doris.nereids.util.Utils;
+import org.apache.doris.statistics.Statistics;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * PhysicalRecursiveUnionAnchor is sentinel plan for must_shuffle
+ */
+public class PhysicalRecursiveUnionAnchor<CHILD_TYPE extends Plan> extends PhysicalUnary<CHILD_TYPE> {
+    private final CTEId cteId;
+
+    public PhysicalRecursiveUnionAnchor(CTEId cteId, LogicalProperties logicalProperties, CHILD_TYPE child) {
+        this(cteId, Optional.empty(), logicalProperties, child);
+    }
+
+    public PhysicalRecursiveUnionAnchor(CTEId cteId, Optional<GroupExpression> groupExpression,
+            LogicalProperties logicalProperties, CHILD_TYPE child) {
+        this(cteId, groupExpression, logicalProperties, PhysicalProperties.ANY, null, child);
+    }
+
+    public PhysicalRecursiveUnionAnchor(CTEId cteId, Optional<GroupExpression> groupExpression,
+            LogicalProperties logicalProperties, @Nullable PhysicalProperties physicalProperties, Statistics statistics,
+            CHILD_TYPE child) {
+        super(PlanType.PHYSICAL_RECURSIVE_CTE_RECURSIVE_CHILD, groupExpression, logicalProperties, physicalProperties,
+                statistics, child);
+        this.cteId = cteId;
+    }
+
+    public CTEId getCteId() {
+        return cteId;
+    }
+
+    @Override
+    public String toString() {
+        return Utils.toSqlStringSkipNull("PhysicalRecursiveCteRecursiveChild",

Review Comment:
   The toString() method uses an outdated class name 'PhysicalRecursiveCteRecursiveChild' instead of the current class name 'PhysicalRecursiveUnionAnchor'.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java:
##########
@@ -183,6 +185,7 @@ public class StatsCalculator extends DefaultPlanVisitor<Statistics, Void> {
     public static double DEFAULT_AGGREGATE_RATIO = 1 / 3.0;
     public static double AGGREGATE_COLUMN_CORRELATION_COEFFICIENT = 0.75;
     public static double DEFAULT_COLUMN_NDV_RATIO = 0.5;
+    public static double RECURSIVE_CTE_EXPAND_RATION = 5.0;

Review Comment:
   Corrected spelling of 'RATION' to 'RATIO'.
   ```suggestion
       public static double RECURSIVE_CTE_EXPAND_RATIO = 5.0;
       @Deprecated
       public static double RECURSIVE_CTE_EXPAND_RATION = RECURSIVE_CTE_EXPAND_RATIO;
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalWorkTableReference.java:
##########
@@ -0,0 +1,149 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.trees.plans.logical;
+
+import org.apache.doris.nereids.memo.GroupExpression;
+import org.apache.doris.nereids.properties.DataTrait;
+import org.apache.doris.nereids.properties.LogicalProperties;
+import org.apache.doris.nereids.trees.expressions.CTEId;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.RelationId;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
+import org.apache.doris.nereids.util.Utils;
+
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * LogicalWorkTableReference, recursive union's producer child will scan WorkTableReference in every iteration.
+ */
+public class LogicalWorkTableReference extends LogicalRelation {
+    private CTEId cteId;
+    private final List<Slot> outputs;
+    private final List<String> nameParts;
+
+    public LogicalWorkTableReference(RelationId relationId, CTEId cteId, List<Slot> outputs, List<String> nameParts) {
+        this(relationId, cteId, outputs, nameParts, Optional.empty(), Optional.empty());
+    }
+
+    private LogicalWorkTableReference(RelationId relationId, CTEId cteId, List<Slot> outputs, List<String> nameParts,
+            Optional<GroupExpression> groupExpression, Optional<LogicalProperties> logicalProperties) {
+        super(relationId, PlanType.LOGICAL_WORK_TABLE_REFERENCE, groupExpression, logicalProperties);
+        this.cteId = cteId;
+        this.outputs = Objects.requireNonNull(outputs);
+        this.nameParts = Objects.requireNonNull(nameParts);
+    }
+
+    public List<String> getNameParts() {
+        return nameParts;
+    }
+
+    public String getTableName() {
+        return nameParts.stream().map(Utils::quoteIfNeeded)
+                .reduce((left, right) -> left + "." + right).orElse("");
+    }
+
+    public CTEId getCteId() {
+        return cteId;
+    }
+
+    @Override
+    public String toString() {
+        return Utils.toSqlString("LogicalWorkTableReference",
+                "cteId", cteId,
+                "cteName", getTableName());
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        if (!super.equals(o)) {
+            return false;
+        }
+        LogicalWorkTableReference that = (LogicalWorkTableReference) o;
+        return cteId.equals(that.cteId) && nameParts.equals(that.nameParts) && outputs.equals(outputs);

Review Comment:
   In the equals method, `outputs.equals(outputs)` compares outputs to itself instead of comparing to `that.outputs`. This should be `outputs.equals(that.outputs)`.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java:
##########
@@ -1519,7 +1578,7 @@ public Statistics computeEmptyRelation(EmptyRelation emptyRelation) {
      * computeRecursiveCte
      */
     public Statistics computeRecursiveCte(RecursiveCte recursiveCte, List<Statistics> childStats) {
-        // TODO: refactor this for one row relation
+        // simliar as computeUnion

Review Comment:
   Corrected spelling of 'simliar' to 'similar'.
   ```suggestion
           // similar as computeUnion
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [refactor](rec_cte)recursive-CTE refactor [doris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #59872:
URL: https://github.com/apache/doris/pull/59872#issuecomment-3766268925

   PR approved by anyone and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org