You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/09/17 04:45:19 UTC

(datafusion) 01/01: fix(docs): Fix code snippet in LogicalPlan docs (#25377)

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

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-25377-0342332e1decac9da7ee2b444b3473ac44c71af8
in repository https://gitbox.apache.org/repos/asf/datafusion.git

commit a436660bd02ccdb4419ba95519c8f465ee53880b
Author: Martin Grigorov <ma...@users.noreply.github.com>
AuthorDate: Thu Sep 17 04:44:52 2026 +0000

    fix(docs): Fix code snippet in LogicalPlan docs (#25377)
    
    ## Which issue does this PR close?
    
    Closes N/A.
    
    ## Rationale for this change
    
    See
    https://docs.rs/datafusion/latest/datafusion/logical_expr/enum.LogicalPlan.html#visiting-and-rewriting-logicalplans
    
    The comment says `// Projection(name, salary)` but the code does
    `project(vec![col("name")])?`. It should include the `col("salary")` too
    
    ## What changes are included in this PR?
    
    The code snippet in the docstring is fixed to match the plan in the
    comments.
    
    ## What is the testing strategy for this PR?
    
    Build the docs and verify that the code snippet matches the comments
    above it.
    
    ## Are there any user-facing changes?
    
    No.
---
 datafusion/expr/src/logical_plan/plan.rs | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs
index cd0aee1322..de6d1667c7 100644
--- a/datafusion/expr/src/logical_plan/plan.rs
+++ b/datafusion/expr/src/logical_plan/plan.rs
@@ -131,7 +131,7 @@ pub use datafusion_common::{JoinConstraint, JoinType};
 /// # fn main() -> Result<()> {
 /// let plan = table_scan(Some("employee"), &employee_schema(), None)?
 ///  .filter(col("salary").gt(lit(1000)))?
-///  .project(vec![col("name")])?
+///  .project(vec![col("name"), col("salary")])?
 ///  .build()?;
 ///
 /// // use apply to walk the plan and collect all expressions
@@ -146,14 +146,16 @@ pub use datafusion_common::{JoinConstraint, JoinType};
 /// }).unwrap();
 ///
 /// // we found the expression in projection and filter
-/// assert_eq!(expressions.len(), 2);
+/// assert_eq!(expressions.len(), 3);
 /// println!("Found expressions: {:?}", expressions);
 /// // found predicate in the Filter: employee.salary > 1000
 /// let salary = Expr::Column(Column::new(Some("employee"), "salary"));
 /// assert!(expressions.contains(&salary.gt(lit(1000))));
-/// // found projection in the Projection: employee.name
+/// // found projection in the Projection: employee.name, employee.salary
 /// let name = Expr::Column(Column::new(Some("employee"), "name"));
+/// let salary = Expr::Column(Column::new(Some("employee"), "salary"));
 /// assert!(expressions.contains(&name));
+/// assert!(expressions.contains(&salary));
 /// # Ok(())
 /// # }
 /// ```
@@ -180,7 +182,7 @@ pub use datafusion_common::{JoinConstraint, JoinType};
 /// use datafusion_common::tree_node::Transformed;
 /// let plan = table_scan(Some("employee"), &employee_schema(), None)?
 ///  .filter(col("salary").gt(lit(1000)))?
-///  .project(vec![col("name")])?
+///  .project(vec![col("name"), col("salary")])?
 ///  .build()?;
 ///
 /// // use transform to rewrite the plan
@@ -203,7 +205,7 @@ pub use datafusion_common::{JoinConstraint, JoinType};
 ///
 /// // we found the filter
 /// assert_eq!(rewritten_plan.display_indent().to_string(),
-/// "Projection: employee.name\
+/// "Projection: employee.name, employee.salary\
 /// \n  Filter: employee.salary < Int32(2000)\
 /// \n    TableScan: employee");
 /// # Ok(())


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org