-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
mark appropriate window functions as nullable: false in logical plan #7638
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 |
---|---|---|
|
@@ -114,19 +114,35 @@ pub enum BuiltInWindowFunction { | |
|
||
impl BuiltInWindowFunction { | ||
fn name(&self) -> &str { | ||
use BuiltInWindowFunction::*; | ||
use BuiltInWindowFunction as F; | ||
match self { | ||
RowNumber => "ROW_NUMBER", | ||
Rank => "RANK", | ||
DenseRank => "DENSE_RANK", | ||
PercentRank => "PERCENT_RANK", | ||
CumeDist => "CUME_DIST", | ||
Ntile => "NTILE", | ||
Lag => "LAG", | ||
Lead => "LEAD", | ||
FirstValue => "FIRST_VALUE", | ||
LastValue => "LAST_VALUE", | ||
NthValue => "NTH_VALUE", | ||
F::RowNumber => "ROW_NUMBER", | ||
F::Rank => "RANK", | ||
F::DenseRank => "DENSE_RANK", | ||
F::PercentRank => "PERCENT_RANK", | ||
F::CumeDist => "CUME_DIST", | ||
F::Ntile => "NTILE", | ||
F::Lag => "LAG", | ||
F::Lead => "LEAD", | ||
F::FirstValue => "FIRST_VALUE", | ||
F::LastValue => "LAST_VALUE", | ||
F::NthValue => "NTH_VALUE", | ||
} | ||
} | ||
|
||
// these values need to stay in sync with the `field` value defined on the physical expressions | ||
pub fn nullable(&self) -> bool { | ||
use BuiltInWindowFunction as F; | ||
match self { | ||
F::RowNumber | F::Ntile | F::Rank | F::CumeDist => false, | ||
// the rest are assumed to be nullable | ||
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. not sure if there is a way that we can derive this from the definitions of the physical plans or elsewhere? Kinda sucks to have this information hardcoded this information in two places (right now, it exists also in the |
||
F::DenseRank | ||
| F::PercentRank | ||
| F::Lag | ||
| F::Lead | ||
| F::FirstValue | ||
| F::LastValue | ||
| F::NthValue => true, | ||
} | ||
} | ||
} | ||
|
@@ -179,6 +195,15 @@ impl WindowFunction { | |
} | ||
} | ||
} | ||
|
||
// pub fn field(&self) { | ||
// match self { | ||
// WindowFunction::AggregateFunction(fun) => fun.field(), | ||
// WindowFunction::BuiltInWindowFunction(fun) => fun.field(), | ||
// WindowFunction::AggregateUDF(fun) => fun.field(), | ||
// WindowFunction::WindowUDF(fun) => fun.field(), | ||
// } | ||
// } | ||
} | ||
|
||
/// Returns the datatype of the built-in window function | ||
|
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.
flyby fix. Using wildcard here means that if a variant were deleted from the enum, the bottom-most variant in the match statement would become a variable catch-all.