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

Split binary_expr.rs into smaller modules #3026

Merged
merged 1 commit into from
Aug 4, 2022

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Aug 3, 2022

NOTE: This change looks large but it is only moving code around

Which issue does this PR close?

re #1474

Rationale for this change

I find it really hard to work on binary.rs. Partly this is because what it is doing is complicated however, I think it can be less complicated than currently, and thus I am trying to unravel the Gordian knot

Part of why this module is complicated is because it has both dispatch logic (figure out what functions to call based on argument types) as well as kernel implementations (both stuff that should eventually end up in arrow as well as things that are datafusion specific).

I think it will be easier to work with if the file were smaller.

What changes are included in this PR?

Thus, break binary.rs into several smaller modules:

  • binary.rs: The main dispatch logic
  • binary/kernels.rs: kernels that are unique to datafusion
  • binary/arrow_kernels.rs: Kernels that are eventually destined for arrow-rs but are in datafusion until we get around tot hat
  • binary/adapte.rs: functions that might change types or names to make them compatible with the main dispatch logic

Are there any user-facing changes?

No

@github-actions github-actions bot added the physical-expr Physical Expressions label Aug 3, 2022
Copy link
Contributor Author

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Even after this change binary.rs is still 2500 lines long, but that is at least a trend in the right direction

@alamb alamb marked this pull request as ready for review August 3, 2022 11:56
@alamb alamb changed the title Split binary_expr.rs into smaller modules Split binary_expr.rs into smaller modules Aug 3, 2022
@alamb alamb added the development-process Related to development process of DataFusion label Aug 3, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #3026 (62e2e70) into master (9a5f17e) will increase coverage by 0.00%.
The diff coverage is 90.43%.

@@           Coverage Diff           @@
##           master    #3026   +/-   ##
=======================================
  Coverage   85.84%   85.85%           
=======================================
  Files         283      286    +3     
  Lines       51658    51666    +8     
=======================================
+ Hits        44347    44356    +9     
+ Misses       7311     7310    -1     
Impacted Files Coverage Δ
datafusion/physical-expr/src/expressions/binary.rs 97.88% <ø> (+2.17%) ⬆️
...on/physical-expr/src/expressions/binary/kernels.rs 72.00% <72.00%> (ø)
...on/physical-expr/src/expressions/binary/adapter.rs 83.33% <83.33%> (ø)
...sical-expr/src/expressions/binary/kernels_arrow.rs 94.02% <94.02%> (ø)
datafusion/common/src/scalar.rs 84.81% <0.00%> (-0.07%) ⬇️
datafusion/expr/src/logical_plan/plan.rs 77.77% <0.00%> (ø)
datafusion/core/src/physical_plan/metrics/value.rs 87.43% <0.00%> (+0.50%) ⬆️
datafusion/expr/src/window_frame.rs 93.27% <0.00%> (+0.84%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@alamb alamb requested a review from andygrove August 3, 2022 20:14
@alamb
Copy link
Contributor Author

alamb commented Aug 3, 2022

cc @avantgardnerio in case you have made changes to the decimal code as part of the arrow 20 possible upgrade

@yjshen
Copy link
Member

yjshen commented Aug 4, 2022

An alternative for splitting binary.rs I could think of:

  • arithmetic.rs for +/-/*/div/mod calculations.
  • predicate.rs for expressions that evals to boolean.
  • bitwise.rs for bit calculations.
  • regex.rs for regex
  • and misc.rs for the remainings.

@alamb
Copy link
Contributor Author

alamb commented Aug 4, 2022

An alternative for splitting binary.rs I could think of:

Thanks @yjshen -- my ideal world is that there are no actual calculation kernels in datafusion (that they are all in arrow) but if we get more kernels into data fusion the split you suggest would be good.

Or maybe I can split kernels.rs into more submodules 🤔

@alamb alamb merged commit d07a775 into apache:master Aug 4, 2022
@alamb alamb removed the development-process Related to development process of DataFusion label Aug 4, 2022
@alamb alamb deleted the alamb/break_up_binary branch August 4, 2022 16:33
@ursabot
Copy link

ursabot commented Aug 4, 2022

Benchmark runs are scheduled for baseline = 3d27987 and contender = d07a775. d07a775 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

/// Concat lhs and rhs String Array, any `NULL` exists on lhs or rhs will come out result `NULL`
/// 1. 'a' || 'b' || 32 = 'ab32'
/// 2. 'a' || NULL = NULL
pub(crate) fn string_concat(left: ArrayRef, right: ArrayRef) -> Result<ArrayRef> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 it seems like this may now be part of arrow:

https://docs.rs/arrow/19.0.0/arrow/compute/kernels/concat_elements/fn.concat_elements_utf8.html

I'll and switch to use that as a follow on PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
physical-expr Physical Expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants