You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2026/08/05 19:20:14 UTC

[PR] docs: Document `WindowFn` and its variants [datafusion]

alamb opened a new pull request, #24118:
URL: https://github.com/apache/datafusion/pull/24118

   ## Which issue does this PR close?
   
   - N/A (documentation only)
   
   ## Rationale for this change
   
   The `WindowFn` enum in `datafusion-physical-expr` has no documentation, and its `Builtin` variant name is misleading: it actually holds any "standard" window function (such as `lead`, `lag`, `row_number`, or `rank`), including user-defined window functions, while the `Aggregate` variant holds an aggregate function (such as `avg` or `sum`) used as a window function. This PR documents that distinction so readers don't have to trace the constructors to figure it out.
   
   ## What changes are included in this PR?
   
   Doc comments on `WindowFn` and its two variants, including links to the `WindowExpr` implementations that create each variant.
   
   ## Are these changes tested?
   
   Covered by CI doc checks; no behavior change. Verified locally with `RUSTDOCFLAGS="-D warnings" cargo doc -p datafusion-physical-expr --no-deps` and `cargo clippy`.
   
   ## Are there any user-facing changes?
   
   Improved API documentation only; no code changes.


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] docs: Document `WindowFn` and add comments [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #24118:
URL: https://github.com/apache/datafusion/pull/24118


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] docs: Document `WindowFn` and add comments [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #24118:
URL: https://github.com/apache/datafusion/pull/24118#discussion_r3770470094


##########
datafusion/physical-expr/src/window/window_expr.rs:
##########
@@ -610,9 +610,16 @@ pub(crate) fn get_orderby_values(order_by_columns: Vec<SortColumn>) -> Vec<Array
     order_by_columns.into_iter().map(|s| s.values).collect()
 }
 
+/// State for incrementally evaluating a window function
+/// within a partition, created by [`WindowExpr::create_window_fn`].
 #[derive(Debug)]
 pub enum WindowFn {
+    /// A "normal" window function, such as `lead` or `lag`, evaluated via a
+    /// [`PartitionEvaluator`]. Despite the name, it is used for all window
+    /// function that is not an aggregate function.

Review Comment:
   Great idea -- done in 00cfe5b83d809474c3619b1127755bb7174c004e



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] docs: Document `WindowFn` and add comments [datafusion]

Posted by "nuno-faria (via GitHub)" <gi...@apache.org>.
nuno-faria commented on code in PR #24118:
URL: https://github.com/apache/datafusion/pull/24118#discussion_r3769753991


##########
datafusion/physical-expr/src/window/window_expr.rs:
##########
@@ -610,9 +610,16 @@ pub(crate) fn get_orderby_values(order_by_columns: Vec<SortColumn>) -> Vec<Array
     order_by_columns.into_iter().map(|s| s.values).collect()
 }
 
+/// State for incrementally evaluating a window function
+/// within a partition, created by [`WindowExpr::create_window_fn`].
 #[derive(Debug)]
 pub enum WindowFn {
+    /// A "normal" window function, such as `lead` or `lag`, evaluated via a
+    /// [`PartitionEvaluator`]. Despite the name, it is used for all window
+    /// function that is not an aggregate function.

Review Comment:
   nit: "... for all window function that is not aggregate function" -> "for all window functions that are not aggregate functions"?



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] docs: Document `WindowFn` and add comments [datafusion]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #24118:
URL: https://github.com/apache/datafusion/pull/24118#issuecomment-5222242599

   ## [Codecov](https://app.codecov.io/gh/apache/datafusion/pull/24118?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 81.06%. Comparing base ([`634f0b3`](https://app.codecov.io/gh/apache/datafusion/commit/634f0b3004af274b0a3d8230710090447c53f352?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`516fe73`](https://app.codecov.io/gh/apache/datafusion/commit/516fe735245c451c04b90b05fcfbdbcf555a18c9?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@           Coverage Diff           @@
   ##             main   #24118   +/-   ##
   =======================================
     Coverage   81.06%   81.06%           
   =======================================
     Files        1107     1107           
     Lines      382191   382191           
     Branches   382191   382191           
   =======================================
   + Hits       309805   309807    +2     
   + Misses      54083    54080    -3     
   - Partials    18303    18304    +1     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion/pull/24118?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] docs: Dcument `WindowFn` and add comments [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #24118:
URL: https://github.com/apache/datafusion/pull/24118#discussion_r3723556015


##########
datafusion/physical-expr/src/window/window_expr.rs:
##########
@@ -602,9 +602,15 @@ pub(crate) fn get_orderby_values(order_by_columns: Vec<SortColumn>) -> Vec<Array
     order_by_columns.into_iter().map(|s| s.values).collect()
 }
 
+/// State for incrementally evaluating a window function
+/// within a partition, created by [`WindowExpr::create_window_fn`].
 #[derive(Debug)]
 pub enum WindowFn {

Review Comment:
   This struct is not technically pub as it is in a `mod` (not `pub mod), though it somehow appears in the WindowExpr trait 🤷 
   
   It might be nice to fix the naming but I think for now just documenting it is helpful
   
   https://docs.rs/datafusion/latest/datafusion/physical_expr/window/trait.WindowExpr.html#tymethod.create_window_fn



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] docs: Document `WindowFn` and add comments [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #24118:
URL: https://github.com/apache/datafusion/pull/24118#issuecomment-5273002685

   Thank you for the review @nuno-faria 


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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