From f1d67df19f8ee5ce8222e9b8904dc213046bcb3a Mon Sep 17 00:00:00 2001 From: Qi Zhu <821684824@qq.com> Date: Sat, 22 Aug 2026 14:13:23 +0800 Subject: [PATCH] refactor(parquet): extract InitialDecoderState from the opener decoder-setup block The decoder-setup block in the opener returned a bare `(decoder, rg_plan, has_row_selection)` tuple. Give it a named `InitialDecoderState` struct so the values carried out of the block stay self-documenting as more are added (e.g. by #23696). Pure refactor, no behavior change. Closes #24286. --- datafusion/datasource-parquet/src/opener/mod.rs | 15 ++++++++++++--- datafusion/datasource-parquet/src/push_decoder.rs | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/datafusion/datasource-parquet/src/opener/mod.rs b/datafusion/datasource-parquet/src/opener/mod.rs index b3ce024d66f1f..3c2ba812aeb7d 100644 --- a/datafusion/datasource-parquet/src/opener/mod.rs +++ b/datafusion/datasource-parquet/src/opener/mod.rs @@ -27,7 +27,8 @@ use crate::access_plan::PreparedAccessPlan; use crate::decoder_projection::DecoderProjection; use crate::page_filter::PagePruningAccessPlanFilter; use crate::push_decoder::{ - DecoderBuilderConfig, PushDecoderStreamState, RgPlanEntry, RowGroupPruner, + DecoderBuilderConfig, InitialDecoderState, PushDecoderStreamState, RgPlanEntry, + RowGroupPruner, }; use crate::row_filter::RowFilterGenerator; use crate::row_group_filter::RowGroupAccessPlanFilter; @@ -1435,7 +1436,11 @@ impl RowGroupsPrunedParquetOpen { prepared.virtual_state.as_deref(), )?; - let (decoder, rg_plan, has_row_selection) = { + let InitialDecoderState { + decoder, + rg_plan, + has_row_selection, + } = { let pushdown_predicate = prepared .pushdown_filters .then_some(prepared.predicate.as_ref()) @@ -1494,7 +1499,11 @@ impl RowGroupsPrunedParquetOpen { } } - (builder.build()?, rg_plan, has_row_selection) + InitialDecoderState { + decoder: builder.build()?, + rg_plan, + has_row_selection, + } }; let predicate_cache_inner_records = diff --git a/datafusion/datasource-parquet/src/push_decoder.rs b/datafusion/datasource-parquet/src/push_decoder.rs index 74d8997198872..f856a0eb7d947 100644 --- a/datafusion/datasource-parquet/src/push_decoder.rs +++ b/datafusion/datasource-parquet/src/push_decoder.rs @@ -111,6 +111,21 @@ pub(crate) struct RgPlanEntry { pub(crate) rg_index: usize, } +/// The initial per-file decoder state the opener builds and hands off to the +/// [`PushDecoderStreamState`] stream driver. +/// +/// Named rather than a bare tuple so the fields carried out of the decoder +/// setup block stay self-documenting as more are added. +pub(crate) struct InitialDecoderState { + /// The freshly built push decoder for this file. + pub(crate) decoder: ParquetPushDecoder, + /// The per-row-group plan, in the physical scan order the decoder reads. + pub(crate) rg_plan: VecDeque, + /// Whether a row selection is live for this scan. Runtime row-group + /// pruning is disabled when it is (see the opener for why). + pub(crate) has_row_selection: bool, +} + /// Runtime row-group pruner driven by a dynamic predicate (e.g. the /// threshold expression a `TopK` operator pushes down). ///