-
Notifications
You must be signed in to change notification settings - Fork 54
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
[Chore] Use helpers to simplify expression handling code #399
Conversation
@@ -134,6 +134,13 @@ pub enum Expression { | |||
Column(String), | |||
/// A struct computed from a Vec of expressions | |||
Struct(Vec<Expression>), | |||
/// A unary operation. | |||
UnaryOperation { |
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.
Seems more logical to order these unary -> binary -> variadic.
@@ -609,23 +590,23 @@ mod tests { | |||
let batch = RecordBatch::try_new(Arc::new(schema.clone()), vec![Arc::new(values)]).unwrap(); | |||
let column = Expression::column("a"); | |||
|
|||
let expression = Box::new(column.clone().add(Expression::Literal(Scalar::Integer(1)))); |
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.
Not sure why these tests were boxing everything... but it's not needed now.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #399 +/- ##
==========================================
- Coverage 78.34% 78.28% -0.07%
==========================================
Files 50 50
Lines 10341 10292 -49
Branches 10341 10292 -49
==========================================
- Hits 8102 8057 -45
+ Misses 1785 1781 -4
Partials 454 454 ☔ View full report in Codecov by Sentry. |
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.
very nice! love the literal's From ergonomics :)
@@ -234,7 +234,7 @@ impl Expression { | |||
} | |||
|
|||
/// Create a new struct expression | |||
pub fn struct_expr(exprs: impl IntoIterator<Item = Self>) -> Self { | |||
pub fn struct_from(exprs: impl IntoIterator<Item = Self>) -> Self { |
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.
flagging breaking change
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.
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.
lgtm!
Kernel provides quite a few helper methods that make it easier to create expressions, but not all call sites take advantage of them. Fix that.
Also update the various binary operation helpers to accept
impl Into<Expression>
as their RHS arg, which allows further simplifications.