alamb commented on code in PR #10813: URL: https://github.com/apache/datafusion/pull/10813#discussion_r1638053895
########## datafusion/core/src/datasource/physical_plan/parquet/mod.rs: ########## @@ -145,6 +145,52 @@ pub use writer::plan_to_parquet; /// custom reader is used, it supplies the metadata directly and this parameter /// is ignored. [`ParquetExecBuilder::with_metadata_size_hint`] for more details. /// +/// * User provided [`ParquetAccessPlan`]s to skip row groups and/or pages +/// based on external information. See "Implementing External Indexes" below +/// +/// # Implementing External Indexes +/// +/// It is possible to restrict the row groups and selections within those row +/// groups that the ParquetExec will consider by providing an initial +/// [`ParquetAccessPlan`] as `extensions` on [`PartitionedFile`]. This can be +/// used to implement external indexes on top of parquet files and select only +/// portions of the files. +/// +/// The `ParquetExec` will try and further reduce any provided +/// `ParquetAccessPlan` further based on the contents of `ParquetMetadata` and +/// other settings. +/// +/// ## Example of providing a ParquetAccessPlan +/// +/// ``` +/// # use std::sync::Arc; +/// # use arrow_schema::{Schema, SchemaRef}; +/// # use datafusion::datasource::listing::PartitionedFile; +/// # use datafusion::datasource::physical_plan::parquet::ParquetAccessPlan; +/// # use datafusion::datasource::physical_plan::{FileScanConfig, ParquetExec}; +/// # use datafusion_execution::object_store::ObjectStoreUrl; +/// # fn schema() -> SchemaRef { +/// # Arc::new(Schema::empty()) +/// # } +/// // create an access plan to scan row group 0, 1 and 3 and skip row groups 2 and 4 +/// let mut access_plan = ParquetAccessPlan::new_all(5); +/// access_plan.skip(2); +/// access_plan.skip(4); +/// // provide the plan as extension to the FileScanConfig +/// let partitioned_file = PartitionedFile::new("my_file.parquet", 1234) +/// .with_extensions(Arc::new(access_plan)); +/// // create a ParquetExec to scan this file +/// let file_scan_config = FileScanConfig::new(ObjectStoreUrl::local_filesystem(), schema()) +/// .with_file(partitioned_file); +/// // this parquet exec will not even try to read row groups 2 and 4. Additional +/// // pruning based on predicates may also happen +/// let exec = ParquetExec::builder(file_scan_config).build(); +/// ``` +/// +/// For a complete example, see the [`parquet_index_advanced` example]). +/// +/// [`parquet_index_advanced` example]: https://github.com/apache/datafusion/blob/main/datafusion-examples/examples/parquet_index_advanced.rs Review Comment: BTW https://github.com/apache/datafusion/pull/10701 (example of how to use this API) is ready for review -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org