You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "nseekhao (via GitHub)" <gi...@apache.org> on 2023/03/20 15:08:26 UTC

[GitHub] [arrow-datafusion] nseekhao opened a new pull request, #5653: Substrait: Add support for WindowFunction

nseekhao opened a new pull request, #5653:
URL: https://github.com/apache/arrow-datafusion/pull/5653

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes # [5390](https://github.com/apache/arrow-datafusion/issues/5390).
   
   # Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   Added the ability to producer/consume Substrait plans with WindowFunction
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   - Producer
     - Added `LogicalPlan::Window` case
       - If the input to this relation is a `ProjectRel`, append `WindowFunction` expressions before returning the parsed `ProjectRel`
       - If the input is NOT a projection, create a `ProjectRel`, add column reference expressions to represent ALL of the fields of the input relation's output. Then append `WindowFunction` expressions.
   - Consumer
     - Added case to parse `WindowFunction`
       - Note that the output `WindowFrameUnits` are currently set to either `Rows` or `Range` depending on whether `ORDER BY` is present in the `WindowFunction`. May need to revisit the cases when frame is explicitly defined.
      - Moved all sort fields logic into `from_substrait_sorts()`
   - Test
     - A single case that tests
       - Single/no argument
       - With/without `ORDER BY`
       - With `PARTITION BY`
       - Multiple `WindowFunction` expressions with column reference
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   Yes. (cases explained above)
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   No
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


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


[GitHub] [arrow-datafusion] andygrove commented on pull request #5653: Substrait: Add support for WindowFunction

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #5653:
URL: https://github.com/apache/arrow-datafusion/pull/5653#issuecomment-1478407716

   @waynexia fyi


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


[GitHub] [arrow-datafusion] nseekhao commented on pull request #5653: Substrait: Add support for WindowFunction

Posted by "nseekhao (via GitHub)" <gi...@apache.org>.
nseekhao commented on PR #5653:
URL: https://github.com/apache/arrow-datafusion/pull/5653#issuecomment-1478612283

   > 
   
   Makes sense. Should I create an issue for this?


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


[GitHub] [arrow-datafusion] andygrove commented on a diff in pull request #5653: Substrait: Add support for WindowFunction

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #5653:
URL: https://github.com/apache/arrow-datafusion/pull/5653#discussion_r1144001450


##########
datafusion/substrait/src/logical_plan/consumer.rs:
##########
@@ -740,6 +804,47 @@ pub async fn from_substrait_rex(
                 "Cast experssion without output type is not allowed".to_string(),
             )),
         },
+        Some(RexType::WindowFunction(window)) => {
+            let fun = match extensions.get(&window.function_reference) {
+                Some(function_name) => Ok(find_df_window_func(function_name)),

Review Comment:
   Should we return an error if `find_df_window_func` returns `None` here? We `unwrap` this later on currently, which could fail?



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


[GitHub] [arrow-datafusion] andygrove commented on pull request #5653: Substrait: Add support for WindowFunction

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #5653:
URL: https://github.com/apache/arrow-datafusion/pull/5653#issuecomment-1478657152

   > > 
   > 
   > Makes sense. Should I create an issue for this?
   
   Yes, that would be great. Thanks.


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


[GitHub] [arrow-datafusion] andygrove merged pull request #5653: Substrait: Add support for WindowFunction

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove merged PR #5653:
URL: https://github.com/apache/arrow-datafusion/pull/5653


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