Skip to content

POC: Add ConfigOptions to ExecutionProps when execution is started #16661

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

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jul 2, 2025

Which issue does this PR close?

I think @Omega359 had other PRs as well

Relates to

Rationale for this change

The need is to access configuration settings (such as the configured timezone) to scalar functions during planning

What changes are included in this PR?

Add an Arc<ConfigOptions> to ExecutionProps when the execution is started

Things I am still not happy about:

  1. This isn't with parity with UDFs yet as the entire SessionContext is saved there (not just config options)
  2. It isn't passed all the way to ScalarUDFs

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added logical-expr Logical plan and expressions core Core DataFusion crate execution Related to the execution crate labels Jul 2, 2025
@@ -152,7 +157,7 @@ impl SessionConfig {
/// assert_eq!(config.options().execution.batch_size, 1024);
/// ```
pub fn options_mut(&mut self) -> &mut ConfigOptions {
&mut self.options
Arc::make_mut(&mut self.options)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the key function call -- it basically does "copy on write" and if there are existing references to the options a new copy is created.

Copy link
Member

Choose a reason for hiding this comment

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

Previously the cost of options_mut was small, now it's considerable.
Not sure it matters, but worth calling out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously the cost of options_mut was small, now it's considerable.
Not sure it matters, but worth calling out.

Technically I think it is considerable only on the first call -- subsequent calls will use the same copy (as I understand from the make_mut docs https://doc.rust-lang.org/std/sync/struct.Arc.html#method.make_mut)

/// Configuration options
options: ConfigOptions,
/// Configuration options, copy on write
options: Arc<ConfigOptions>,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea is to pass this pointer down into the ExecutionProps

@@ -152,7 +157,7 @@ impl SessionConfig {
/// assert_eq!(config.options().execution.batch_size, 1024);
/// ```
pub fn options_mut(&mut self) -> &mut ConfigOptions {
&mut self.options
Arc::make_mut(&mut self.options)
Copy link
Member

Choose a reason for hiding this comment

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

Previously the cost of options_mut was small, now it's considerable.
Not sure it matters, but worth calling out.

Comment on lines +108 to +110
/// Returns the configuration properties for this execution
/// if the execution has started
pub fn config_options(&self) -> Option<&Arc<ConfigOptions>> {
Copy link
Member

Choose a reason for hiding this comment

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

the with_query_execution_start_time makes / used to make ExecutionProps "as started"
these call sites should be updated as well

@alamb
Copy link
Contributor Author

alamb commented Jul 3, 2025

I don't have time to push this along for the next few days, but maybe we can restart it if / when @Omega359 needs access to the config options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate execution Related to the execution crate logical-expr Logical plan and expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants