Skip to content

Commit a22da9f

Browse files
adriangbclaude
andcommitted
refactor: express keep_ordering decision as an explicit match
Replace the nested `if all_non_overlapping { if is_exact {..} else {..} } else { false }` in `rebuild_with_source` with a `match (all_non_overlapping, is_exact)`. No behaviour change — the three arms map one-to-one to the prior branches and make the "overlap → drop", "exact → keep", "inexact → re-validate" cases explicit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 42149c2 commit a22da9f

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

datafusion/datasource/src/file_scan_config/sort_pushdown.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -169,20 +169,24 @@ impl FileScanConfig {
169169
//
170170
// This interleaving is actually beneficial because SPM pulls from both
171171
// partitions concurrently, keeping parallel I/O active.
172-
let keep_ordering = if all_non_overlapping {
173-
if is_exact {
174-
true
175-
} else {
176-
// Re-validate: now that files are sorted, can the
177-
// request be satisfied?
178-
//
179-
// Same NULL guard as `try_sort_file_groups_by_statistics`:
180-
// we cannot claim Exact if any non-last file contains
181-
// NULLs in the sort columns. With NULLS LAST those
182-
// NULLs sit after all non-null rows in the file, so
183-
// when the next file's non-nulls are smaller than the
184-
// previous file's max, they'd appear *after* the NULLs
185-
// in the concatenated stream — breaking the ordering.
172+
let keep_ordering = match (all_non_overlapping, is_exact) {
173+
// Files still overlap after the stats sort — the combined
174+
// stream isn't ordered, so `output_ordering` must be dropped.
175+
(false, _) => false,
176+
// Source already had validated ordering and the post-sort
177+
// files still don't overlap — Exact carries through.
178+
(true, true) => true,
179+
// Source returned `Inexact`; re-validate against the
180+
// reordered file groups to decide whether to upgrade.
181+
//
182+
// Same NULL guard as `try_sort_file_groups_by_statistics`:
183+
// we cannot claim Exact if any non-last file contains
184+
// NULLs in the sort columns. With NULLS LAST those
185+
// NULLs sit after all non-null rows in the file, so
186+
// when the next file's non-nulls are smaller than the
187+
// previous file's max, they'd appear *after* the NULLs
188+
// in the concatenated stream — breaking the ordering.
189+
(true, false) => {
186190
let projected_schema = new_config.projected_schema()?;
187191
let projection_indices = new_config
188192
.file_source
@@ -201,8 +205,6 @@ impl FileScanConfig {
201205
new_eq_props.ordering_satisfy(order.iter().cloned())?
202206
}
203207
}
204-
} else {
205-
false
206208
};
207209

208210
if !keep_ordering {

0 commit comments

Comments
 (0)