Skip to content

Commit fdefa5c

Browse files
committed
Determine if we can use PageIndex for predicate
1 parent 4abae3b commit fdefa5c

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

  • datafusion/core/src/datasource/physical_plan/parquet

datafusion/core/src/datasource/physical_plan/parquet/row_filter.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,19 @@ fn size_of_columns(
301301
/// columns are sorted. Sorted columns may be queried more efficiently in the presence of
302302
/// a PageIndex.
303303
fn columns_sorted(
304-
_columns: &BTreeSet<usize>,
305-
_metadata: &ParquetMetaData,
304+
columns: &BTreeSet<usize>,
305+
metadata: &ParquetMetaData,
306306
) -> Result<bool> {
307-
// TODO How do we know this?
307+
// For now we only set sorted with single col with pageIndex
308+
if columns.len() == 1 && metadata.column_index().is_some() {
309+
for row_group_num in 0..metadata.num_row_groups() {
310+
if !metadata.column_index().unwrap()[row_group_num][*columns.get(&0).unwrap()].is_sorted() {
311+
// If any Row Group is not sorted we can't assume we can use the PageIndex.
312+
return Ok(false);
313+
}
314+
}
315+
return Ok(true);
316+
}
308317
Ok(false)
309318
}
310319

0 commit comments

Comments
 (0)