This is an automated email from the ASF dual-hosted git repository.

agrove pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/master by this push:
     new 5bdd55b53 Add to_unoptimized_plan (#3344)
5bdd55b53 is described below

commit 5bdd55b532430fb16a27ef3ab19feb567af0c72e
Author: Ian Alexander Joiner <[email protected]>
AuthorDate: Fri Sep 2 17:19:38 2022 -0400

    Add to_unoptimized_plan (#3344)
    
    * Add to_raw_logical_plan
    
    * rename the new func
    
    * change func name to to_unoptimized_plan
---
 datafusion/core/src/dataframe.rs | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/datafusion/core/src/dataframe.rs b/datafusion/core/src/dataframe.rs
index bb572b7d5..cf7803494 100644
--- a/datafusion/core/src/dataframe.rs
+++ b/datafusion/core/src/dataframe.rs
@@ -520,7 +520,13 @@ impl DataFrame {
         self.plan.schema()
     }
 
-    /// Return the logical plan represented by this DataFrame.
+    /// Return the unoptimized logical plan represented by this DataFrame.
+    pub fn to_unoptimized_plan(&self) -> LogicalPlan {
+        // Optimize the plan first for better UX
+        self.plan.clone()
+    }
+
+    /// Return the optimized logical plan represented by this DataFrame.
     pub fn to_logical_plan(&self) -> Result<LogicalPlan> {
         // Optimize the plan first for better UX
         let state = self.session_state.read().clone();
@@ -1258,6 +1264,17 @@ mod tests {
         );
 
         let df_renamed = df.with_column_renamed("t1.c1", "AAA")?;
+
+        assert_eq!("\
+        Projection: #t1.c1 AS AAA, #t1.c2, #t1.c3, #t2.c1, #t2.c2, #t2.c3\
+        \n  Limit: skip=None, fetch=1\
+        \n    Sort: #t1.c1 ASC NULLS FIRST, #t1.c2 ASC NULLS FIRST, #t1.c3 ASC 
NULLS FIRST, #t2.c1 ASC NULLS FIRST, #t2.c2 ASC NULLS FIRST, #t2.c3 ASC NULLS 
FIRST\
+        \n      Inner Join: #t1.c1 = #t2.c1\
+        \n        TableScan: t1\
+        \n        TableScan: t2",
+            format!("{:?}", df_renamed.to_unoptimized_plan())
+        );
+
         assert_eq!("\
         Projection: #t1.c1 AS AAA, #t1.c2, #t1.c3, #t2.c1, #t2.c2, #t2.c3\
         \n  Limit: skip=None, fetch=1\

Reply via email to