-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Minor: Move get_equal_orderings into BuiltInWindowFunctionExpr
, remove BuiltInWindowFunctionExpr::as_any
#6619
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 1 commit
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 |
---|---|---|
|
@@ -17,14 +17,16 @@ | |
|
||
//! Defines physical expression for `row_number` that can evaluated at runtime during query execution | ||
|
||
use crate::equivalence::OrderingEquivalenceBuilder; | ||
use crate::expressions::Column; | ||
use crate::window::partition_evaluator::PartitionEvaluator; | ||
use crate::window::window_expr::{BuiltinWindowState, NumRowsState}; | ||
use crate::window::BuiltInWindowFunctionExpr; | ||
use crate::PhysicalExpr; | ||
use crate::{PhysicalExpr, PhysicalSortExpr}; | ||
use arrow::array::{ArrayRef, UInt64Array}; | ||
use arrow::datatypes::{DataType, Field}; | ||
use arrow_schema::SortOptions; | ||
use datafusion_common::{Result, ScalarValue}; | ||
use std::any::Any; | ||
use std::ops::Range; | ||
use std::sync::Arc; | ||
|
||
|
@@ -42,11 +44,6 @@ impl RowNumber { | |
} | ||
|
||
impl BuiltInWindowFunctionExpr for RowNumber { | ||
/// Return a reference to Any that can be used for downcasting | ||
fn as_any(&self) -> &dyn Any { | ||
self | ||
} | ||
|
||
fn field(&self) -> Result<Field> { | ||
let nullable = false; | ||
let data_type = DataType::UInt64; | ||
|
@@ -61,6 +58,24 @@ impl BuiltInWindowFunctionExpr for RowNumber { | |
&self.name | ||
} | ||
|
||
fn add_equal_orderings(&self, builder: &mut OrderingEquivalenceBuilder) { | ||
// Only the built-in `RowNumber` window function introduces a new | ||
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. Maybe we can replace comment 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 in commit ad16502 |
||
// ordering: | ||
let schema = builder.schema(); | ||
if let Some((idx, field)) = schema.column_with_name(self.name()) { | ||
let column = Column::new(field.name(), idx); | ||
let options = SortOptions { | ||
descending: false, | ||
nulls_first: false, | ||
}; // ASC, NULLS LAST | ||
let rhs = PhysicalSortExpr { | ||
expr: Arc::new(column) as _, | ||
options, | ||
}; | ||
builder.add_equal_conditions(vec![rhs]); | ||
} | ||
} | ||
|
||
fn create_evaluator(&self) -> Result<Box<dyn PartitionEvaluator>> { | ||
Ok(Box::<NumRowsEvaluator>::default()) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of the PR is to remove this special case for RowNumber (which I did by hoisting it into the trait)