jcsherin commented on code in PR #12893:
URL: https://github.com/apache/datafusion/pull/12893#discussion_r1797731274


##########
datafusion/functions-window/src/rank.rs:
##########
@@ -39,37 +39,73 @@ use field::WindowUDFFieldArgs;
 define_udwf_and_expr!(
     Rank,
     rank,
-    "Returns rank of the current row with gaps. Same as `row_number` of its 
first peer"
+    "Returns rank of the current row with gaps. Same as `row_number` of its 
first peer",
+    Rank::basic
+);
+
+define_udwf_and_expr!(
+    DenseRank,
+    dense_rank,
+    "Returns rank of the current row without gaps. This function counts peer 
groups",
+    Rank::dense_rank
+);
+
+define_udwf_and_expr!(
+    PercentRank,
+    percent_rank,
+    "Returns the relative rank of the current row: (rank - 1) / (total rows - 
1)",
+    Rank::percent_rank
 );
 
 /// rank expression
 #[derive(Debug)]
 pub struct Rank {
+    name: String,
     signature: Signature,
+    rank_type: RankType,
 }
 
 impl Rank {
-    /// Create a new `rank` function
-    pub fn new() -> Self {
+    pub fn new(name: String, rank_type: RankType) -> Self {
         Self {
+            name,
             signature: Signature::any(0, Volatility::Immutable),
+            rank_type,
         }
     }
-}
 
-impl Default for Rank {
-    fn default() -> Self {
-        Self::new()
+    pub fn basic() -> Self {
+        Rank::new("rank".to_string(), RankType::Basic)
+    }
+
+    pub fn dense_rank() -> Self {
+        Rank::new("dense_rank".to_string(), RankType::Dense)
+    }
+
+    pub fn percent_rank() -> Self {
+        Rank::new("percent_rank".to_string(), RankType::Percent)
+    }
+
+    /// Get rank_type of the rank in window function with order by
+    pub fn get_type(&self) -> RankType {
+        self.rank_type

Review Comment:
   It is ok to remove `Rank::get_type()` as it is not used anywhere.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to