tustvold commented on code in PR #4679:
URL: https://github.com/apache/arrow-datafusion/pull/4679#discussion_r1053288596


##########
datafusion/core/src/dataframe.rs:
##########
@@ -505,17 +505,40 @@ impl DataFrame {
         self.plan.schema()
     }
 
-    /// Return the unoptimized logical plan represented by this DataFrame.
+    /// Return the unoptimized logical plan
+    pub fn logical_plan(&self) -> &LogicalPlan {
+        &self.plan
+    }
+
+    /// Return the logical plan represented by this DataFrame without running 
the optimizers
+    ///
+    /// Note: This method should not be used outside testing, as it loses the 
snapshot
+    /// of the [`SessionState`] attached to this [`DataFrame`] and 
consequently subsequent
+    /// operations may take place against a different state
     pub fn to_unoptimized_plan(self) -> LogicalPlan {
         self.plan
     }
 
     /// Return the optimized logical plan represented by this DataFrame.
-    pub fn to_logical_plan(self) -> Result<LogicalPlan> {
+    ///
+    /// Note: This method should not be used outside testing, as it loses the 
snapshot
+    /// of the [`SessionState`] attached to this [`DataFrame`] and 
consequently subsequent
+    /// operations may take place against a different state
+    pub fn to_optimized_plan(self) -> Result<LogicalPlan> {
         // Optimize the plan first for better UX
         self.session_state.optimize(&self.plan)
     }
 
+    /// Return the optimized logical plan represented by this DataFrame.
+    ///
+    /// Note: This method should not be used outside testing, as it loses the 
snapshot
+    /// of the [`SessionState`] attached to this [`DataFrame`] and 
consequently subsequent
+    /// operations may take place against a different state
+    #[deprecated(note = "Use DataFrame::to_optimized_plan")]

Review Comment:
   I opted to deprecate this method as it was a touch confusing, having a 
method that actually performed a potentially mutating optimization pass. 



-- 
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]

Reply via email to