Skip to content

Commit

Permalink
Combine the logic of rank, dense_rank and percent_rank udwf to reduce…
Browse files Browse the repository at this point in the history
… duplications (#12893)

* wip: combining the logic of rank, dense_rank and percent_rank udwf

* added test for dense_rank and percent_rank

* removed unnecessary files and fixed issue for percent_rank and dense_rank udwf

* updated the module imports for the percent_rank and dense_rank udwfs

* removed data_type field from then rank struct

* fixed function-window macros

* removed unused function

* module doc updated for rank.rs
  • Loading branch information
jatin510 authored Oct 16, 2024
1 parent 399e840 commit 747001a
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 448 deletions.
3 changes: 1 addition & 2 deletions datafusion/core/tests/fuzz_cases/window_fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ use datafusion_physical_expr::{PhysicalExpr, PhysicalSortExpr};
use test_utils::add_empty_batches;

use datafusion::functions_window::row_number::row_number_udwf;
use datafusion_functions_window::dense_rank::dense_rank_udwf;
use datafusion_functions_window::rank::rank_udwf;
use datafusion_functions_window::rank::{dense_rank_udwf, rank_udwf};
use hashbrown::HashMap;
use rand::distributions::Alphanumeric;
use rand::rngs::StdRng;
Expand Down
205 changes: 0 additions & 205 deletions datafusion/functions-window/src/dense_rank.rs

This file was deleted.

10 changes: 3 additions & 7 deletions datafusion/functions-window/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ use datafusion_expr::WindowUDF;

#[macro_use]
pub mod macros;
pub mod dense_rank;
pub mod percent_rank;
pub mod rank;
pub mod row_number;

/// Fluent-style API for creating `Expr`s
pub mod expr_fn {
pub use super::dense_rank::dense_rank;
pub use super::percent_rank::percent_rank;
pub use super::rank::rank;
pub use super::rank::{dense_rank, percent_rank, rank};
pub use super::row_number::row_number;
}

Expand All @@ -49,8 +45,8 @@ pub fn all_default_window_functions() -> Vec<Arc<WindowUDF>> {
vec![
row_number::row_number_udwf(),
rank::rank_udwf(),
dense_rank::dense_rank_udwf(),
percent_rank::percent_rank_udwf(),
rank::dense_rank_udwf(),
rank::percent_rank_udwf(),
]
}
/// Registers all enabled packages with a [`FunctionRegistry`]
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions-window/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ macro_rules! create_udwf_expr {
($UDWF:ident, $OUT_FN_NAME:ident, $DOC:expr) => {
paste::paste! {
#[doc = " Create a [`WindowFunction`](datafusion_expr::Expr::WindowFunction) expression for"]
#[doc = concat!(" [`", stringify!($UDWF), "`] user-defined window function.")]
#[doc = concat!(" `", stringify!($UDWF), "` user-defined window function.")]
#[doc = ""]
#[doc = concat!(" ", $DOC)]
pub fn $OUT_FN_NAME() -> datafusion_expr::Expr {
Expand All @@ -316,7 +316,7 @@ macro_rules! create_udwf_expr {
($UDWF:ident, $OUT_FN_NAME:ident, [$($PARAM:ident),+], $DOC:expr) => {
paste::paste! {
#[doc = " Create a [`WindowFunction`](datafusion_expr::Expr::WindowFunction) expression for"]
#[doc = concat!(" [`", stringify!($UDWF), "`] user-defined window function.")]
#[doc = concat!(" `", stringify!($UDWF), "` user-defined window function.")]
#[doc = ""]
#[doc = concat!(" ", $DOC)]
pub fn $OUT_FN_NAME(
Expand Down
Loading

0 comments on commit 747001a

Please sign in to comment.