Skip to content

Test experiment load page index with columns #16329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ ahash = { version = "0.8", default-features = false, features = [
"runtime-rng",
] }
apache-avro = { version = "0.17", default-features = false }
arrow = { version = "55.1.0", features = [
arrow = { path = "/Users/zhuqi/arrow-rs/arrow", features = [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you want to experiment, need to change this to the branch:

apache/arrow-rs#7624

"prettyprint",
"chrono-tz",
] }
arrow-buffer = { version = "55.0.0", default-features = false }
arrow-flight = { version = "55.1.0", features = [
arrow-buffer = {path = "/Users/zhuqi/arrow-rs/arrow-buffer", default-features = false }
arrow-flight = { path = "/Users/zhuqi/arrow-rs/arrow-flight", features = [
"flight-sql-experimental",
] }
arrow-ipc = { version = "55.0.0", default-features = false, features = [
arrow-ipc = { path = "/Users/zhuqi/arrow-rs/arrow-ipc", default-features = false, features = [
"lz4",
] }
arrow-ord = { version = "55.0.0", default-features = false }
arrow-schema = { version = "55.0.0", default-features = false }
arrow-ord = { path = "/Users/zhuqi/arrow-rs/arrow-ord", default-features = false }
arrow-schema = { path = "/Users/zhuqi/arrow-rs/arrow-schema", default-features = false }
async-trait = "0.1.88"
bigdecimal = "0.4.8"
bytes = "1.10"
Expand Down Expand Up @@ -151,7 +151,7 @@ itertools = "0.14"
log = "^0.4"
object_store = { version = "0.12.0", default-features = false }
parking_lot = "0.12"
parquet = { version = "55.1.0", default-features = false, features = [
parquet = {path = "/Users/zhuqi/arrow-rs/parquet", default-features = false, features = [
"arrow",
"async",
"object_store",
Expand Down
12 changes: 6 additions & 6 deletions datafusion/datasource-parquet/src/opener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,15 @@ impl FileOpener for ParquetOpener {
&predicate_creation_errors,
);

// The page index is not stored inline in the parquet footer so the
// code above may not have read the page index structures yet. If we
// need them for reading and they aren't yet loaded, we need to load them now.
if should_enable_page_index(enable_page_index, &page_pruning_predicate) {
let col_idxs: Vec<usize> = page_pruning_predicate.as_ref().unwrap().columns_needed();
reader_metadata = load_page_index(
reader_metadata,
&mut async_file_reader,
// Since we're manually loading the page index the option here should not matter but we pass it in for consistency
options.with_page_index(true),
&col_idxs,
)
.await?;
.await?;
}

metadata_timer.stop();
Expand Down Expand Up @@ -418,6 +416,7 @@ async fn load_page_index<T: AsyncFileReader>(
reader_metadata: ArrowReaderMetadata,
input: &mut T,
options: ArrowReaderOptions,
col_idxs: &[usize],
) -> Result<ArrowReaderMetadata> {
let parquet_metadata = reader_metadata.metadata();
let missing_column_index = parquet_metadata.column_index().is_none();
Expand All @@ -432,7 +431,8 @@ async fn load_page_index<T: AsyncFileReader>(
.unwrap_or_else(|e| e.as_ref().clone());
let mut reader =
ParquetMetaDataReader::new_with_metadata(m).with_page_indexes(true);
reader.load_page_index(input).await?;
reader.load_page_index_with_columns(input, col_idxs).await?;

let new_parquet_metadata = reader.finish()?;
let new_arrow_reader =
ArrowReaderMetadata::try_new(Arc::new(new_parquet_metadata), options)?;
Expand Down
11 changes: 11 additions & 0 deletions datafusion/datasource-parquet/src/page_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,17 @@ impl PagePruningAccessPlanFilter {
pub fn filter_number(&self) -> usize {
self.predicates.len()
}

/// Returns the columns needed to evaluate the page predicates
pub fn columns_needed(&self) -> Vec<usize> {
self.predicates.iter()
.filter_map(|pp| pp.required_columns().single_column())
.map(|column| {
// Get the index of the column in the parquet file
column.index()
})
.collect()
}
}

fn update_selection(
Expand Down
Loading