Skip to content
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

Merged
merged 7 commits into from
Oct 18, 2024

Conversation

scovich
Copy link
Collaborator

@scovich scovich commented Oct 15, 2024

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.

@scovich scovich requested review from nicklan and hntd187 October 15, 2024 21:30
@@ -134,6 +134,13 @@ pub enum Expression {
Column(String),
/// A struct computed from a Vec of expressions
Struct(Vec<Expression>),
/// A unary operation.
UnaryOperation {
Copy link
Collaborator Author

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))));
Copy link
Collaborator Author

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.

@scovich scovich changed the title [Chore] Use existing helpers to simplify expression handling code [Chore] Use helpers to simplify expression handling code Oct 15, 2024
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 89.58333% with 10 lines in your changes missing coverage. Please review.

Project coverage is 78.28%. Comparing base (6205711) to head (1eac26e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
kernel/src/engine/arrow_conversion.rs 28.57% 4 Missing and 1 partial ⚠️
ffi/src/expressions.rs 0.00% 4 Missing ⚠️
kernel/src/actions/deletion_vector.rs 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added the breaking-change Change that will require a version bump label Oct 17, 2024
Copy link
Collaborator

@zachschuermann zachschuermann left a 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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flagging breaking change

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry, semver check caught it :)
image

Copy link
Collaborator

@nicklan nicklan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@scovich scovich merged commit 284db10 into delta-io:main Oct 18, 2024
14 checks passed
@scovich scovich deleted the cleanup-expression-creation branch November 8, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Change that will require a version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants