Samyak2 commented on code in PR #18739:
URL: https://github.com/apache/datafusion/pull/18739#discussion_r2556818994
##########
datafusion/physical-optimizer/src/optimizer.rs:
##########
@@ -38,23 +38,103 @@ use crate::update_aggr_exprs::OptimizeAggregateOrder;
use crate::limit_pushdown_past_window::LimitPushPastWindows;
use datafusion_common::config::ConfigOptions;
-use datafusion_common::Result;
+use datafusion_common::{internal_err, Result};
+use datafusion_execution::config::{Extensions, SessionConfig};
use datafusion_physical_plan::ExecutionPlan;
-/// `PhysicalOptimizerRule` transforms one ['ExecutionPlan'] into another which
+/// Context for optimizing physical plans.
+///
+/// This context provides access to session configuration and optimizer
extensions.
+///
+/// Similar to [`TaskContext`] which provides context during execution,
+/// `OptimizerContext` provides context during optimization.
+///
+/// [`TaskContext`]:
https://docs.rs/datafusion/latest/datafusion/execution/struct.TaskContext.html
+#[derive(Debug, Clone)]
+pub struct OptimizerContext {
+ /// Session configuration
+ session_config: SessionConfig,
+}
+
+impl OptimizerContext {
+ /// Create a new OptimizerContext
+ pub fn new(session_config: SessionConfig) -> Self {
+ Self { session_config }
+ }
+
+ /// Return a reference to the session configuration
+ pub fn session_config(&self) -> &SessionConfig {
+ &self.session_config
+ }
+
+ /// Return a reference to the configuration options
+ ///
+ /// This is a convenience method that returns the [`ConfigOptions`]
+ /// from the [`SessionConfig`].
+ pub fn options(&self) -> &Arc<ConfigOptions> {
+ self.session_config.options()
+ }
+
+ /// Return a reference to the extensions
+ pub fn extensions(&self) -> &Arc<Extensions> {
+ self.session_config.extensions()
+ }
+}
Review Comment:
That makes sense actually. I only need extensions from the session config.
We could expose just the required fields from the inner session_config. Unless,
of course, there's already a requirement for the session config.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]