Commit 07cf68c
proto: round-trip SortExec's TopK dynamic filter
Add optional PhysicalExprNode dynamic_filter field to SortExecNode.
Emit from to_proto via SortExec::dynamic_filter(); on deserialize parse
it and install via SortExec::with_dynamic_filter after the usual
with_fetch / with_preserve_partitioning chain. The with_fetch step may
auto-create a TopK filter when fetch is set; with_dynamic_filter then
replaces it with the one from the sender so the id matches the
pushed-down scan's copy (shared via the id cache).
The accompanying SQL test uses an ORDER BY ... LIMIT query over a
parquet file, round-trips via DeduplicatingProtoConverter, executes,
and verifies:
- SortExec and the scan's pushed predicate share the same expression_id
- generation == 1 before execution (filter not yet updated)
- generation > 1 after execution (TopK's update took effect) AND
the scan-side wrapper observes the same generation — proving that
updates propagate across the round-trip via shared `inner`.
Scan row-count pruning isn't asserted because the single row-group
parquet file decodes all rows before the filter is updated (a TopK
scan-pruning optimization concern, orthogonal to proto correctness).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 5af73db commit 07cf68c
5 files changed
Lines changed: 158 additions & 1 deletion
File tree
- datafusion/proto
- proto
- src
- generated
- physical_plan
- tests/cases
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1352 | 1352 | | |
1353 | 1353 | | |
1354 | 1354 | | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
1355 | 1360 | | |
1356 | 1361 | | |
1357 | 1362 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1680 | 1680 | | |
1681 | 1681 | | |
1682 | 1682 | | |
1683 | | - | |
| 1683 | + | |
| 1684 | + | |
1684 | 1685 | | |
1685 | 1686 | | |
1686 | 1687 | | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
1687 | 1705 | | |
1688 | 1706 | | |
1689 | 1707 | | |
| |||
3125 | 3143 | | |
3126 | 3144 | | |
3127 | 3145 | | |
| 3146 | + | |
| 3147 | + | |
| 3148 | + | |
| 3149 | + | |
| 3150 | + | |
| 3151 | + | |
| 3152 | + | |
3128 | 3153 | | |
3129 | 3154 | | |
3130 | 3155 | | |
| |||
3135 | 3160 | | |
3136 | 3161 | | |
3137 | 3162 | | |
| 3163 | + | |
3138 | 3164 | | |
3139 | 3165 | | |
3140 | 3166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3178 | 3178 | | |
3179 | 3179 | | |
3180 | 3180 | | |
| 3181 | + | |
| 3182 | + | |
| 3183 | + | |
| 3184 | + | |
| 3185 | + | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
| 3189 | + | |
| 3190 | + | |
| 3191 | + | |
| 3192 | + | |
3181 | 3193 | | |
3182 | 3194 | | |
3183 | 3195 | | |
| |||
3190 | 3202 | | |
3191 | 3203 | | |
3192 | 3204 | | |
| 3205 | + | |
| 3206 | + | |
| 3207 | + | |
| 3208 | + | |
| 3209 | + | |
| 3210 | + | |
| 3211 | + | |
| 3212 | + | |
| 3213 | + | |
| 3214 | + | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
| 3221 | + | |
| 3222 | + | |
| 3223 | + | |
| 3224 | + | |
| 3225 | + | |
| 3226 | + | |
| 3227 | + | |
| 3228 | + | |
| 3229 | + | |
| 3230 | + | |
| 3231 | + | |
| 3232 | + | |
| 3233 | + | |
| 3234 | + | |
| 3235 | + | |
| 3236 | + | |
| 3237 | + | |
| 3238 | + | |
| 3239 | + | |
| 3240 | + | |
| 3241 | + | |
| 3242 | + | |
| 3243 | + | |
| 3244 | + | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
| 3251 | + | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
| 3257 | + | |
| 3258 | + | |
| 3259 | + | |
| 3260 | + | |
| 3261 | + | |
| 3262 | + | |
| 3263 | + | |
| 3264 | + | |
| 3265 | + | |
| 3266 | + | |
| 3267 | + | |
| 3268 | + | |
| 3269 | + | |
| 3270 | + | |
| 3271 | + | |
| 3272 | + | |
| 3273 | + | |
| 3274 | + | |
| 3275 | + | |
| 3276 | + | |
| 3277 | + | |
| 3278 | + | |
| 3279 | + | |
| 3280 | + | |
| 3281 | + | |
| 3282 | + | |
| 3283 | + | |
| 3284 | + | |
| 3285 | + | |
| 3286 | + | |
| 3287 | + | |
| 3288 | + | |
| 3289 | + | |
| 3290 | + | |
| 3291 | + | |
| 3292 | + | |
| 3293 | + | |
| 3294 | + | |
3193 | 3295 | | |
3194 | 3296 | | |
3195 | 3297 | | |
| |||
0 commit comments