Commit 6ac210b
[improvement](fe) TopN lazy materialization support struct/variant nested column pruning (#63736)
Extend TopN lazy materialization to defer reading complex-type base
columns
(struct, variant, map, array) until after TopN filtering, and expand the
scope to all non-trivial projection expressions.
## Core Changes
**PullUpProjectExprUnderTopN** (new CustomRewriter):
- Two-pass design: Collector walks the plan tree top-down to find
qualifying
TopNs, then walks into descendants (through Join/Filter) to find
Projects
with pull-able expressions. Replacer simplifies found Projects bottom-up
and adds upper Projects to restore pulled-up expressions.
- Eligible expressions: Alias with non-trivial child (not Slot/Literal),
not referenced by TopN order keys, no NoneMovableFunction.
- Excludes: CTE Producers (output mapping safety), Join/Filter
conditions
that reference pulled-up outputs (cleared/removed).
**LazyMaterializeTopN** (simplified):
- Expression pull-up moved from physical PlanPostProcessor to logical
CustomRewriter, eliminating hard-coded
`MERGE_SORT→Distribute→LOCAL_SORT→Project`
shape walking. Now only handles MaterializeNode insertion.
**OperativeColumnDerive**:
- Skip PreferPushDownProject input slots from operative propagation so
complex-type base columns can be lazy.
**Other**:
- `PhysicalLazyMaterialize`: propagate access paths to lazy output slots
for nested column/subPath pruning on BE.
- `MaterializationNode`/`PlanNode`: fix nested column display in
EXPLAIN.
- `NoneMovableFunction`: fix missing interface name.
- Session variable `enable_topn_expr_pullup` for rollback.
**Tests**:
- `topn_expr_pullup`: 15 test cases covering struct/variant/map/array,
non-PPD
expressions, joins, column order preservation, negative cases.
- `topn_lazy_nested_column_pruning`: 17 test cases for struct/variant
nested
pruning + map/array lazy mat + multi-level variant nesting.
- Updated 48 shape_check .out files to reflect new plan shapes.
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
### Release note
None
### 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:
apache/doris-website#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 -->
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent c27fd0b commit 6ac210b
90 files changed
Lines changed: 4770 additions & 1796 deletions
File tree
- fe/fe-core/src
- main/java/org/apache/doris
- nereids
- jobs/executor
- processor/post
- materialize
- rules
- exploration/mv
- rewrite
- trees/plans/physical
- planner
- qe
- test/java/org/apache/doris/nereids
- postprocess
- processor/post/materialize
- rules/rewrite
- regression-test
- data
- nereids_rules_p0
- column_pruning
- infer_set_operator_distinct
- shape_check
- clickbench
- tpcds_sf1000_nopkfk/shape
- tpcds_sf1000
- bs_downgrade_shape
- hint
- shape
- tpcds_sf100
- noStatsRfPrune
- no_stats_shape
- rf_prune
- shape
- tpcds_sf10t_orc/shape
- suites
- external_table_p0
- hive
- tvf
- nereids_rules_p0/column_pruning
- query_p0/compress_materialize
- variant_p0
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| |||
718 | 719 | | |
719 | 720 | | |
720 | 721 | | |
721 | | - | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
722 | 725 | | |
723 | 726 | | |
724 | 727 | | |
| |||
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
74 | | - | |
75 | | - | |
76 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
81 | 91 | | |
82 | 92 | | |
83 | 93 | | |
| |||
Lines changed: 122 additions & 68 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| |||
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
56 | | - | |
| 60 | + | |
| 61 | + | |
57 | 62 | | |
58 | 63 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | 64 | | |
71 | 65 | | |
72 | 66 | | |
73 | 67 | | |
74 | | - | |
| 68 | + | |
75 | 69 | | |
76 | 70 | | |
77 | 71 | | |
| |||
85 | 79 | | |
86 | 80 | | |
87 | 81 | | |
88 | | - | |
| 82 | + | |
89 | 83 | | |
90 | 84 | | |
91 | 85 | | |
92 | 86 | | |
93 | 87 | | |
94 | 88 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
102 | 105 | | |
103 | 106 | | |
104 | | - | |
105 | | - | |
106 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
107 | 125 | | |
108 | 126 | | |
109 | | - | |
| 127 | + | |
| 128 | + | |
110 | 129 | | |
111 | 130 | | |
112 | 131 | | |
113 | 132 | | |
114 | 133 | | |
115 | 134 | | |
116 | 135 | | |
117 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
118 | 149 | | |
119 | 150 | | |
120 | 151 | | |
| |||
127 | 158 | | |
128 | 159 | | |
129 | 160 | | |
130 | | - | |
131 | 161 | | |
132 | 162 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | 163 | | |
137 | 164 | | |
138 | 165 | | |
| |||
142 | 169 | | |
143 | 170 | | |
144 | 171 | | |
145 | | - | |
146 | | - | |
147 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
148 | 175 | | |
149 | 176 | | |
150 | 177 | | |
| |||
154 | 181 | | |
155 | 182 | | |
156 | 183 | | |
157 | | - | |
158 | | - | |
159 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
160 | 187 | | |
161 | 188 | | |
162 | 189 | | |
163 | | - | |
164 | 190 | | |
165 | 191 | | |
166 | 192 | | |
167 | 193 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | 194 | | |
172 | 195 | | |
173 | 196 | | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
183 | 206 | | |
184 | | - | |
| 207 | + | |
185 | 208 | | |
186 | 209 | | |
187 | 210 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | 211 | | |
199 | 212 | | |
200 | 213 | | |
| |||
208 | 221 | | |
209 | 222 | | |
210 | 223 | | |
211 | | - | |
212 | 224 | | |
213 | 225 | | |
214 | 226 | | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
219 | 272 | | |
220 | 273 | | |
221 | 274 | | |
| |||
245 | 298 | | |
246 | 299 | | |
247 | 300 | | |
248 | | - | |
| 301 | + | |
| 302 | + | |
249 | 303 | | |
250 | | - | |
| 304 | + | |
| 305 | + | |
251 | 306 | | |
252 | 307 | | |
253 | | - | |
254 | 308 | | |
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
84 | 95 | | |
85 | 96 | | |
86 | 97 | | |
87 | 98 | | |
88 | | - | |
| 99 | + | |
89 | 100 | | |
90 | 101 | | |
91 | 102 | | |
| |||
0 commit comments