Registry Mirror
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
dd0a9fb
fix: updated output_ordering to use Vec<Option<LexOrdering>>
destrex271 Sep 3, 2025
4faaa22
fix: updated functions in file_scan_config to use Option<LexOrdering>…
destrex271 Sep 3, 2025
4c937be
fix: output_ordering wrapped with Option; functions modified accordingly
destrex271 Sep 4, 2025
b091c4a
chore(deps): bump aws-config from 1.8.5 to 1.8.6 (#17386)
dependabot[bot] Sep 3, 2025
43f26a7
Refactor DataSourceExec::try_swapping_with_projection to simplify and…
adriangb Sep 4, 2025
dbd5059
minor: make dict_from_values public (#17376)
parthchandra Sep 4, 2025
25c2e54
chore: add memory catalog test to handle table removal before schema …
caicancai Sep 4, 2025
fd74ca3
chore(deps): bump actions/setup-node from 4.4.0 to 5.0.0 (#17410)
dependabot[bot] Sep 4, 2025
a036d74
chore(deps): bump actions/stale from 9.1.0 to 10.0.0 (#17409)
dependabot[bot] Sep 4, 2025
7f1a5f8
chore(deps): bump actions/labeler from 5.0.0 to 6.0.0 (#17408)
dependabot[bot] Sep 4, 2025
5792621
fix: set distinct_count to Absent when merging statistics (#17385)
adriangb Sep 4, 2025
5d57d69
doc: Document caveats of `swap_inputs()` interface in join executors …
2010YOUY01 Sep 4, 2025
14efaaf
Fix syntax error in DDL documentation example (#17412)
pepijnve Sep 4, 2025
48c53bb
#17392 Avoid panic when 'with order' expression could not be converte…
pepijnve Sep 4, 2025
c613b2e
chore(deps): bump apache-avro from 0.17.0 to 0.20.0 (#16092)
dependabot[bot] Sep 4, 2025
f4c0f89
chore(deps): bump actions/setup-python from 5.6.0 to 6.0.0 (#17413)
dependabot[bot] Sep 4, 2025
0de726c
Test grouping by FixedSizeList (#17415)
findepi Sep 4, 2025
ac4eb16
Add MSRV bump to 1.86.0 to upgrade guide (#17406)
findepi Sep 4, 2025
56f91bc
re-export physical_expr_adapter (#17414)
adriangb Sep 4, 2025
9055ac7
Use a struct for ProjectionExpr (#17398)
adriangb Sep 4, 2025
2150959
Benchmark window function with multiple partitioning columns (#17402)
findepi Sep 4, 2025
81e75f1
Fix PartialOrd for Window (#17393)
findepi Sep 4, 2025
833af60
Make EncryptionFactory async (#17342)
adamreeve Sep 4, 2025
1257f11
Use DataFusionError instead of ArrowError in FileOpenFuture (#17397)
adriangb Sep 4, 2025
a57b0d4
fix: removed testing folders
destrex271 Sep 4, 2025
0339a4c
fix: Remove duplicate filter from `CrossJoin` unparsing (#17382)
jonathanc-n Sep 5, 2025
6189c6d
fix: set IPC alignment based on schema (#17363)
ding-young Sep 5, 2025
a3b0c95
Memory datasource protobuf support (#17290)
lewiszlw Sep 5, 2025
fa3aa4d
Merge branch 'main' into fix/output_ordering
destrex271 Sep 5, 2025
File filter
Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 73 additions & 53 deletions datafusion/datasource/src/file_scan_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub struct FileScanConfig {
/// The partitioning columns
pub table_partition_cols: Vec<FieldRef>,
/// All equivalent lexicographical orderings that describe the schema.
pub output_ordering: Vec<LexOrdering>,
pub output_ordering: Vec<Option<LexOrdering>>,
/// File compression type
pub file_compression_type: FileCompressionType,
/// Are new lines in values supported for CSVOptions
Expand Down Expand Up @@ -270,7 +270,7 @@ pub struct FileScanConfigBuilder {
constraints: Option<Constraints>,
file_groups: Vec<FileGroup>,
statistics: Option<Statistics>,
output_ordering: Vec<LexOrdering>,
output_ordering: Vec<Option<LexOrdering>>,
file_compression_type: Option<FileCompressionType>,
new_lines_in_values: Option<bool>,
batch_size: Option<usize>,
Expand Down Expand Up @@ -383,7 +383,7 @@ impl FileScanConfigBuilder {

/// Set the output ordering of the files
pub fn with_output_ordering(mut self, output_ordering: Vec<LexOrdering>) -> Self {
self.output_ordering = output_ordering;
self.output_ordering = output_ordering.into_iter().map(Some).collect();
self
}

Expand Down Expand Up @@ -528,7 +528,10 @@ impl DataSource for FileScanConfig {
match t {
DisplayFormatType::Default | DisplayFormatType::Verbose => {
let schema = self.projected_schema();
let orderings = get_projected_output_ordering(self, &schema);
let orderings = get_projected_output_ordering(self, &schema)
.into_iter()
.flatten()
.collect();

write!(f, "file_groups=")?;
FileGroupsDisplay(&self.file_groups).fmt_as(t, f)?;
Expand Down Expand Up @@ -785,19 +788,28 @@ impl FileScanConfig {
/// Project the schema, constraints, and the statistics on the given column indices
pub fn project(&self) -> (SchemaRef, Constraints, Statistics, Vec<LexOrdering>) {
if self.projection.is_none() && self.table_partition_cols.is_empty() {
let ordering: Vec<LexOrdering> = self.output_ordering
.clone()
.into_iter()
.flatten()
.collect();

return (
Arc::clone(&self.file_schema),
self.constraints.clone(),
self.file_source.statistics().unwrap().clone(),
self.output_ordering.clone(),
ordering,
);
}

let schema = self.projected_schema();
let constraints = self.projected_constraints();
let stats = self.projected_stats();

let output_ordering = get_projected_output_ordering(self, &schema);
let output_ordering = get_projected_output_ordering(self, &schema)
.into_iter()
.flatten()
.collect();

(schema, constraints, stats, output_ordering)
}
Expand Down Expand Up @@ -1044,7 +1056,9 @@ impl DisplayAs for FileScanConfig {
write!(f, ", limit={limit}")?;
}

display_orderings(f, &orderings)?;
// Remove 'None' orderings i.e. Unsorted orderings
let flattened_orderings: Vec<LexOrdering> = orderings.iter().flatten().cloned().collect();
display_orderings(f, &flattened_orderings)?;

if !self.constraints.is_empty() {
write!(f, ", {}", self.constraints)?;
Expand Down Expand Up @@ -1364,63 +1378,69 @@ fn create_output_array(
fn get_projected_output_ordering(
base_config: &FileScanConfig,
projected_schema: &SchemaRef,
) -> Vec<LexOrdering> {
) -> Vec<Option<LexOrdering>> {
let mut all_orderings = vec![];
for output_ordering in &base_config.output_ordering {
let mut new_ordering = vec![];
for PhysicalSortExpr { expr, options } in output_ordering.iter() {
if let Some(col) = expr.as_any().downcast_ref::<Column>() {
let name = col.name();
if let Some((idx, _)) = projected_schema.column_with_name(name) {
// Compute the new sort expression (with correct index) after projection:
new_ordering.push(PhysicalSortExpr::new(
Arc::new(Column::new(name, idx)),
*options,
));
continue;
if let Some(ordering) = output_ordering{
for PhysicalSortExpr { expr, options } in ordering.iter() {
if let Some(col) = expr.as_any().downcast_ref::<Column>() {
let name = col.name();
if let Some((idx, _)) = projected_schema.column_with_name(name) {
// Compute the new sort expression (with correct index) after projection:
new_ordering.push(PhysicalSortExpr::new(
Arc::new(Column::new(name, idx)),
*options,
));
continue;
}
}
// Cannot find expression in the projected_schema, stop iterating
// since rest of the orderings are violated
break;
}
// Cannot find expression in the projected_schema, stop iterating
// since rest of the orderings are violated
break;
}

let Some(new_ordering) = LexOrdering::new(new_ordering) else {
continue;
};

// Check if any file groups are not sorted
if base_config.file_groups.iter().any(|group| {
if group.len() <= 1 {
// File groups with <= 1 files are always sorted
return false;
}
let new_ordering = LexOrdering::new(new_ordering);

let statistics = match MinMaxStatistics::new_from_files(
&new_ordering,
projected_schema,
base_config.projection.as_deref(),
group.iter(),
) {
Ok(statistics) => statistics,
Err(e) => {
log::trace!("Error fetching statistics for file group: {e}");
// we can't prove that it's ordered, so we have to reject it
return true;
// Check if any file groups are not sorted
if base_config.file_groups.iter().any(|group| {
if group.len() <= 1 {
// File groups with <= 1 files are always sorted
return false;
}
};

!statistics.is_sorted()
}) {
debug!(
"Skipping specified output ordering {:?}. \
Some file groups couldn't be determined to be sorted: {:?}",
base_config.output_ordering[0], base_config.file_groups
);
continue;
let Some(ref ordering) = new_ordering else {
return false;
};

let statistics = match MinMaxStatistics::new_from_files(
ordering,
projected_schema,
base_config.projection.as_deref(),
group.iter(),
) {
Ok(statistics) => statistics,
Err(e) => {
log::trace!("Error fetching statistics for file group: {e}");
// we can't prove that it's ordered, so we have to reject it
return true;
}
};

!statistics.is_sorted()
}) {
debug!(
"Skipping specified output ordering {:?}. \
Some file groups couldn't be determined to be sorted: {:?}",
base_config.output_ordering[0], base_config.file_groups
);
continue;
}
all_orderings.push(new_ordering);
} else {
all_orderings.push(None);
}

all_orderings.push(new_ordering);
}
all_orderings
}
Expand Down
3 changes: 3 additions & 0 deletions datafusion/physical-expr/src/equivalence/properties/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ impl EquivalenceProperties {
orderings: impl IntoIterator<Item = impl IntoIterator<Item = PhysicalSortExpr>>,
) -> Self {
let eq_group = EquivalenceGroup::default();
// let orderings = orderings.into_iter().map(|maybe_exprs| {
// maybe_exprs.into_iter().flatten()
// });
let oeq_class = OrderingEquivalenceClass::new(orderings);
// Here, we can avoid performing a full normalization, and get by with
// only removing constants because the equivalence group is empty.
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-plan/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ impl fmt::Display for ProjectSchemaDisplay<'_> {
}
}

pub fn display_orderings(f: &mut Formatter, orderings: &[LexOrdering]) -> fmt::Result {
pub fn display_orderings(f: &mut Formatter, orderings: &Vec<LexOrdering>) -> fmt::Result {
if !orderings.is_empty() {
let start = if orderings.len() == 1 {
", output_ordering="
Expand Down
6 changes: 4 additions & 2 deletions datafusion/proto/src/physical_plan/to_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,10 @@ pub fn serialize_file_scan_config(

let mut output_orderings = vec![];
for order in &conf.output_ordering {
let ordering = serialize_physical_sort_exprs(order.to_vec(), codec)?;
output_orderings.push(ordering)
if let Some(ord) = order{
let ordering = serialize_physical_sort_exprs(ord.to_vec(), codec)?;
output_orderings.push(ordering)
}
}

// Fields must be added to the schema so that they can persist in the protobuf,
Expand Down
1 change: 0 additions & 1 deletion parquet-testing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be changed

Submodule parquet-testing deleted from 107b36
1 change: 0 additions & 1 deletion testing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Submodule testing deleted from d2a137