You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "vibhatha (via GitHub)" <gi...@apache.org> on 2023/04/11 02:31:52 UTC

[GitHub] [arrow] vibhatha commented on a diff in pull request #34651: GH-32763: [C++] Add FromProto for fetch & sort

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

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