-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
docs: document SessionConfig #8771
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,69 @@ use std::{ | |
|
||
use datafusion_common::{config::ConfigOptions, Result, ScalarValue}; | ||
|
||
/// Configuration options for Execution context | ||
/// Configuration options for [`SessionContext`]. | ||
/// | ||
/// Can be passed to [`SessionContext::new_with_config`] to customize the configuration of DataFusion. | ||
/// | ||
/// Options can be set using namespaces keys with `.` as the separator, where the | ||
/// namespace determines which configuration struct the value to routed to. All | ||
/// built-in options are under the `datafusion` namespace. | ||
/// | ||
/// For example, the key `datafusion.execution.batch_size` will set [ExecutionOptions::batch_size][datafusion_common::config::ExecutionOptions::batch_size], | ||
/// because [ConfigOptions::execution] is [ExecutionOptions][datafusion_common::config::ExecutionOptions]. Similarly, the key | ||
/// `datafusion.execution.parquet.pushdown_filters` will set [ParquetOptions::pushdown_filters][datafusion_common::config::ParquetOptions::pushdown_filters], | ||
/// since [ExecutionOptions::parquet][datafusion_common::config::ExecutionOptions::parquet] is [ParquetOptions][datafusion_common::config::ParquetOptions]. | ||
/// | ||
/// Some options have convenience methods. For example [SessionConfig::with_batch_size] is | ||
/// shorthand for setting `datafusion.execution.batch_size`. | ||
/// | ||
/// ``` | ||
/// use datafusion_execution::config::SessionConfig; | ||
/// use datafusion_common::ScalarValue; | ||
/// | ||
/// let config = SessionConfig::new() | ||
/// .set("datafusion.execution.batch_size", ScalarValue::UInt64(Some(1234))) | ||
/// .set_bool("datafusion.execution.parquet.pushdown_filters", true); | ||
/// | ||
/// assert_eq!(config.batch_size(), 1234); | ||
/// assert_eq!(config.options().execution.batch_size, 1234); | ||
/// assert_eq!(config.options().execution.parquet.pushdown_filters, true); | ||
/// ``` | ||
/// | ||
/// You can also directly mutate the options via [SessionConfig::options_mut]. | ||
/// So the following is equivalent to the above: | ||
/// | ||
/// ``` | ||
/// # use datafusion_execution::config::SessionConfig; | ||
/// # use datafusion_common::ScalarValue; | ||
/// # | ||
/// let mut config = SessionConfig::new(); | ||
/// config.options_mut().execution.batch_size = 1234; | ||
/// config.options_mut().execution.parquet.pushdown_filters = true; | ||
/// # | ||
/// # assert_eq!(config.batch_size(), 1234); | ||
/// # assert_eq!(config.options().execution.batch_size, 1234); | ||
/// # assert_eq!(config.options().execution.parquet.pushdown_filters, true); | ||
/// ``` | ||
/// | ||
/// ## Built-in options | ||
/// | ||
/// | Namespace | Config struct | | ||
/// | --------- | ------------- | | ||
/// | `datafusion.catalog` | [CatalogOptions][datafusion_common::config::CatalogOptions] | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also mention add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
/// | `datafusion.execution` | [ExecutionOptions][datafusion_common::config::ExecutionOptions] | | ||
/// | `datafusion.execution.aggregate` | [AggregateOptions][datafusion_common::config::AggregateOptions] | | ||
/// | `datafusion.execution.parquet` | [ParquetOptions][datafusion_common::config::ParquetOptions] | | ||
/// | `datafusion.optimizer` | [OptimizerOptions][datafusion_common::config::OptimizerOptions] | | ||
/// | `datafusion.sql_parser` | [SqlParserOptions][datafusion_common::config::SqlParserOptions] | | ||
/// | `datafusion.explain` | [ExplainOptions][datafusion_common::config::ExplainOptions] | | ||
/// | ||
/// ## Custom configuration | ||
/// | ||
/// Configuration options can be extended. See [SessionConfig::with_extension] for details. | ||
/// | ||
/// [`SessionContext`]: https://docs.rs/datafusion/latest/datafusion/execution/context/struct.SessionContext.html | ||
/// [`SessionContext::new_with_config`]: https://docs.rs/datafusion/latest/datafusion/execution/context/struct.SessionContext.html#method.new_with_config | ||
#[derive(Clone, Debug)] | ||
pub struct SessionConfig { | ||
/// Configuration options | ||
|
@@ -62,6 +124,35 @@ impl SessionConfig { | |
Ok(ConfigOptions::from_string_hash_map(settings)?.into()) | ||
} | ||
|
||
/// Return a handle to the configuration options. | ||
/// | ||
/// Can be used to read the current configuration. | ||
/// | ||
/// ``` | ||
/// use datafusion_execution::config::SessionConfig; | ||
/// | ||
/// let config = SessionConfig::new(); | ||
/// assert!(config.options().execution.batch_size > 0); | ||
/// ``` | ||
pub fn options(&self) -> &ConfigOptions { | ||
&self.options | ||
} | ||
|
||
/// Return a mutable handle to the configuration options. | ||
/// | ||
/// Can be used to set configuration options. | ||
/// | ||
/// ``` | ||
/// use datafusion_execution::config::SessionConfig; | ||
/// | ||
/// let mut config = SessionConfig::new(); | ||
/// config.options_mut().execution.batch_size = 1024; | ||
/// assert_eq!(config.options().execution.batch_size, 1024); | ||
/// ``` | ||
pub fn options_mut(&mut self) -> &mut ConfigOptions { | ||
&mut self.options | ||
} | ||
|
||
/// Set a configuration option | ||
pub fn set(mut self, key: &str, value: ScalarValue) -> Self { | ||
self.options.set(key, &value.to_string()).unwrap(); | ||
|
@@ -346,16 +437,6 @@ impl SessionConfig { | |
&mut self.options | ||
} | ||
|
||
/// Return a handle to the configuration options. | ||
pub fn options(&self) -> &ConfigOptions { | ||
&self.options | ||
} | ||
|
||
/// Return a mutable handle to the configuration options. | ||
pub fn options_mut(&mut self) -> &mut ConfigOptions { | ||
&mut self.options | ||
} | ||
|
||
/// Add extensions. | ||
/// | ||
/// Extensions can be used to attach extra data to the session config -- e.g. tracing information or caches. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this because it was the option I was seeking out with the keyword
late materialization
.