raulcd commented on code in PR #13327:
URL: https://github.com/apache/arrow/pull/13327#discussion_r892323043


##########
python/pyarrow/_compute.pyx:
##########
@@ -2047,6 +2047,60 @@ class RandomOptions(_RandomOptions):
         self._set_options(length, initializer)
 
 
+cdef class _RankOptions(FunctionOptions):
+
+    _tiebreaker_map = {
+        "min": CRankOptionsTiebreaker_Min,
+        "max": CRankOptionsTiebreaker_Max,
+        "first": CRankOptionsTiebreaker_First,
+        "dense": CRankOptionsTiebreaker_Dense,
+    }
+
+    def _set_options(self, sort_keys, null_placement, tiebreaker):
+        cdef vector[CSortKey] c_sort_keys
+        for name, order in sort_keys:
+            c_sort_keys.push_back(
+                CSortKey(tobytes(name), unwrap_sort_order(order))
+            )
+        try:
+            self.wrapped.reset(
+                new CRankOptions(c_sort_keys, 
unwrap_null_placement(null_placement), self._tiebreaker_map[tiebreaker])
+            )
+        except KeyError:
+            _raise_invalid_function_option(tiebreaker, "tiebreaker")
+
+
+class RankOptions(_RankOptions):
+    """
+    Options for the `rank` function.
+
+    Parameters
+    ----------
+    sort_keys : sequence of (name, order) tuples, optional
+        Names of field/column keys to sort the input on,
+        along with the order each field/column is sorted in.
+        Accepted values for `order` are "ascending", "descending".

Review Comment:
   @pitrou I've removed the use of `sort_keys` and implemented only `order`. 
From what I understand the rank function is always going to be used on an array 
so I am not sure at this point it makes much sense to expose the `sort_keys` 
instead of using just `ascending`/`descending` as you suggested.
   See this commit 221505f4876b97367cf60fbaec219753552c75ec



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

Reply via email to