You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/30 12:30:29 UTC

[GitHub] [arrow-datafusion] mustafasrepo opened a new pull request, #4441: Feature/partition evaluator

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

   # 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 #4440.
   
   # 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.  
   -->
   Handling of the Builtin Window Functions (such as `ROW_NUMBER`, `FIRST_VALUE`, etc.) are quite different than accumulators (such as `SUM`, `AVG`, etc.) even though they have significant commonalities. We can increase readability if we make their implementation similar in spirit; and we can increase code reuse in this way too. This PR changes the `PartitionEvaluator` trait such that it resembles the `Accumulator` trait.
   
   # 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.
   -->
   The `create_evaluator` method of `BuiltInWindowFunctionExpr` no longer takes a record batch during creation. Instead; when we are doing evaluation, we pass the relevant batch section to the `evaluate` method of the `PartitionEvaluator` trait.
   
   # 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)?
   -->
   N.A (Existing tests should work after refactor)
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   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] alamb commented on a diff in pull request #4441: Refactor Builtin Window Function Implementation

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #4441:
URL: https://github.com/apache/arrow-datafusion/pull/4441#discussion_r1037270435


##########
datafusion/physical-expr/src/window/window_expr.rs:
##########
@@ -99,15 +99,32 @@ pub trait WindowExpr: Send + Sync + Debug {
             .collect()
     }
 
+    /// get order by columns, empty if absent
+    fn order_by_columns(&self, batch: &RecordBatch) -> Result<Vec<SortColumn>> {
+        self.order_by()
+            .iter()
+            .map(|e| e.evaluate_to_sort_column(batch))
+            .collect::<Result<Vec<SortColumn>>>()
+    }
+
     /// get sort columns that can be used for peer evaluation, empty if absent
     fn sort_columns(&self, batch: &RecordBatch) -> Result<Vec<SortColumn>> {
         let mut sort_columns = self.partition_columns(batch)?;
-        let order_by_columns = self
-            .order_by()
-            .iter()
-            .map(|e| e.evaluate_to_sort_column(batch))
-            .collect::<Result<Vec<SortColumn>>>()?;
+        let order_by_columns = self.order_by_columns(batch)?;
         sort_columns.extend(order_by_columns);
         Ok(sort_columns)
     }
+
+    /// Get values columns(argument of Window Function)
+    /// and order by columns (columns of the ORDER BY expression)used in evaluators
+    fn get_values_orderbys(

Review Comment:
   👍  this is a nice refactor of common functionality



##########
datafusion/physical-expr/src/window/row_number.rs:
##########
@@ -61,10 +60,7 @@ impl BuiltInWindowFunctionExpr for RowNumber {
         &self.name
     }
 
-    fn create_evaluator(
-        &self,
-        _batch: &RecordBatch,
-    ) -> Result<Box<dyn PartitionEvaluator>> {
+    fn create_evaluator(&self) -> Result<Box<dyn PartitionEvaluator>> {

Review Comment:
   👍 



-- 
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] ursabot commented on pull request #4441: Refactor Builtin Window Function Implementation

Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #4441:
URL: https://github.com/apache/arrow-datafusion/pull/4441#issuecomment-1333976084

   Benchmark runs are scheduled for baseline = a0485e7e0fc69aa5dca35339108142a0fd1dc703 and contender = 09aea09b6e7bd2950c0f57296ccb1a1995570057. 09aea09b6e7bd2950c0f57296ccb1a1995570057 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/03aed9136f1b4325beae90ae8d35faef...d17708e63fdf45978d237068108d36ca/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/2f999fbb339d41fdac2228ae4abc5808...950bd4ffe06045139e7699445cc36a22/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/964e5a61381b453782c8e41264fe39b3...9f5d78b8e5ce4e36b95207cb6afbc7e2/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/cf3944e59f224206b57677d015b6f12e...a578ac0ae7124f7faa2034f585049f09/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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] ozankabak commented on pull request #4441: Refactor Builtin Window Function Implementation

Posted by GitBox <gi...@apache.org>.
ozankabak commented on PR #4441:
URL: https://github.com/apache/arrow-datafusion/pull/4441#issuecomment-1333942774

   FYI, we did an internal review of this -- please let us know if there are any concerns and we will be happy to address them if necessary.


-- 
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] alamb merged pull request #4441: Refactor Builtin Window Function Implementation

Posted by GitBox <gi...@apache.org>.
alamb merged PR #4441:
URL: https://github.com/apache/arrow-datafusion/pull/4441


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