vibhatha commented on code in PR #34651:
URL: https://github.com/apache/arrow/pull/34651#discussion_r1162239721


##########
cpp/src/arrow/engine/substrait/relation_internal.cc:
##########
@@ -367,6 +367,23 @@ ARROW_ENGINE_EXPORT Result<DeclarationInfo> 
MakeAggregateDeclaration(
 
 }  // namespace internal
 
+namespace {
+
+bool IsSortNullsFirst(const substrait::SortField::SortDirection& direction) {
+  return direction % 2 == 1;
+}
+
+compute::SortOrder SortOrderFromDirection(
+    const substrait::SortField::SortDirection& direction) {
+  if (direction < 3) {
+    return compute::SortOrder::Ascending;

Review Comment:
   Do we consider `UNSPECIFIED` as Ascending? 
   
   Here: 
   
   ```proto
    enum SortDirection {
       SORT_DIRECTION_UNSPECIFIED = 0;
       SORT_DIRECTION_ASC_NULLS_FIRST = 1;
       SORT_DIRECTION_ASC_NULLS_LAST = 2;
       SORT_DIRECTION_DESC_NULLS_FIRST = 3;
       SORT_DIRECTION_DESC_NULLS_LAST = 4;
       SORT_DIRECTION_CLUSTERED = 5;
     }
   ```
   
   I assume since the 1, 2 are Ascending, `<3` is to pick the first three as 
Ascending. 



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