Skip to content
Merged
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
21 changes: 20 additions & 1 deletion datafusion/core/src/execution/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ impl SessionContext {
};
let options = ListingOptions {
format: file_format,
collect_stat: false,
collect_stat: self.copied_config().collect_statistics,
file_extension: file_extension.to_owned(),
target_partitions: self.copied_config().target_partitions,
table_partition_cols: cmd.table_partition_cols.clone(),
Expand Down Expand Up @@ -1092,6 +1092,8 @@ pub const REPARTITION_AGGREGATIONS: &str = "repartition_aggregations";
pub const REPARTITION_WINDOWS: &str = "repartition_windows";
/// Session Configuration entry name for 'PARQUET_PRUNING'
pub const PARQUET_PRUNING: &str = "parquet_pruning";
/// Session Configuration entry name for 'COLLECT_STATISTICS'
pub const COLLECT_STATISTICS: &str = "collect_statistics";

/// Map that holds opaque objects indexed by their type.
///
Expand Down Expand Up @@ -1149,6 +1151,8 @@ pub struct SessionConfig {
pub repartition_windows: bool,
/// Should DataFusion parquet reader using the predicate to prune data
pub parquet_pruning: bool,
/// Should DataFusion collect statistics after listing files
pub collect_statistics: bool,
/// Configuration options
pub config_options: Arc<RwLock<ConfigOptions>>,
/// Opaque extensions.
Expand All @@ -1167,6 +1171,7 @@ impl Default for SessionConfig {
repartition_aggregations: true,
repartition_windows: true,
parquet_pruning: true,
collect_statistics: false,
config_options: Arc::new(RwLock::new(ConfigOptions::new())),
// Assume no extensions by default.
extensions: HashMap::with_capacity_and_hasher(
Expand Down Expand Up @@ -1269,6 +1274,12 @@ impl SessionConfig {
self
}

/// Enables or disables the collection of statistics after listing files
pub fn with_collect_statistics(mut self, enabled: bool) -> Self {
self.collect_statistics = enabled;
self
}

/// Get the currently configured batch size
pub fn batch_size(&self) -> usize {
self.config_options
Expand Down Expand Up @@ -1312,6 +1323,11 @@ impl SessionConfig {
PARQUET_PRUNING.to_owned(),
format!("{}", self.parquet_pruning),
);
map.insert(
COLLECT_STATISTICS.to_owned(),
format!("{}", self.collect_statistics),
);

map
}

Expand Down Expand Up @@ -1771,6 +1787,9 @@ impl TaskContext {
.with_parquet_pruning(
props.get(PARQUET_PRUNING).unwrap().parse().unwrap(),
)
.with_collect_statistics(
props.get(COLLECT_STATISTICS).unwrap().parse().unwrap(),
)
}
}
TaskProperties::SessionConfig(session_config) => session_config.clone(),
Expand Down