-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Improve performance of constant aggregate window expression #16234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
1212063
c4cc4ce
cf3d1b0
ff1bc94
2e24bad
f40020a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -186,6 +186,10 @@ pub trait AggregateWindowExpr: WindowExpr { | |||||
accumulator: &mut Box<dyn Accumulator>, | ||||||
) -> Result<ScalarValue>; | ||||||
|
||||||
/// Indicates whether this window function always produces the same result | ||||||
/// for all rows in the partition. | ||||||
fn is_constant(&self) -> bool; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
nit: It would be great to be more specific. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I'll address it a bit later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||||||
|
||||||
/// Evaluates the window function against the batch. | ||||||
fn aggregate_evaluate(&self, batch: &RecordBatch) -> Result<ArrayRef> { | ||||||
let mut accumulator = self.get_accumulator()?; | ||||||
|
@@ -272,8 +276,13 @@ pub trait AggregateWindowExpr: WindowExpr { | |||||
not_end: bool, | ||||||
) -> Result<ArrayRef> { | ||||||
let values = self.evaluate_args(record_batch)?; | ||||||
let order_bys = get_orderby_values(self.order_by_columns(record_batch)?); | ||||||
|
||||||
if self.is_constant() { | ||||||
accumulator.update_batch(&values)?; | ||||||
let value = accumulator.evaluate()?; | ||||||
return value.to_array_of_size(record_batch.num_rows()); | ||||||
} | ||||||
let order_bys = get_orderby_values(self.order_by_columns(record_batch)?); | ||||||
let most_recent_row_order_bys = most_recent_row | ||||||
.map(|batch| self.order_by_columns(batch)) | ||||||
.transpose()? | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.