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

[Minor] Reduce code duplication creating ScalarValue::List #3197

Merged
merged 2 commits into from
Aug 20, 2022

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Aug 18, 2022

Which issue does this PR close?

N/A

Rationale for this change

While working on #3122 I found it quite painful to make ScalarValue::Lists and noticed that all over the code the same code got copy/pasted around

What changes are included in this PR?

  1. Add ScalarValue::new_list
  2. Remove much duplication

Are there any user-facing changes?

No

@github-actions github-actions bot added physical-expr Physical Expressions sql SQL Planner labels Aug 18, 2022
value,
Box::new(Field::new("item", nested_type.data_type().clone(), true)),
)
ScalarValue::new_list(value, nested_type.data_type().clone())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The whole PR is just doing this transformation over and over again

@@ -648,6 +648,11 @@ impl ScalarValue {
ScalarValue::IntervalMonthDayNano(Some(val))
}

/// Create a new nullable ScalarValue::List with the specified child_type
pub fn new_list(scalars: Option<Vec<Self>>, child_type: DataType) -> Self {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the new function

@codecov-commenter
Copy link

Codecov Report

Merging #3197 (60084cb) into master (929eb6d) will decrease coverage by 0.01%.
The diff coverage is 96.59%.

@@            Coverage Diff             @@
##           master    #3197      +/-   ##
==========================================
- Coverage   85.87%   85.86%   -0.02%     
==========================================
  Files         291      291              
  Lines       52885    52846      -39     
==========================================
- Hits        45415    45375      -40     
- Misses       7470     7471       +1     
Impacted Files Coverage Δ
datafusion/sql/src/planner.rs 81.30% <50.00%> (+0.05%) ⬆️
.../physical-expr/src/aggregate/array_agg_distinct.rs 79.41% <89.47%> (-0.78%) ⬇️
datafusion/common/src/scalar.rs 84.65% <100.00%> (-0.10%) ⬇️
...atafusion/physical-expr/src/aggregate/array_agg.rs 95.74% <100.00%> (-0.18%) ⬇️
...sion/physical-expr/src/aggregate/count_distinct.rs 95.00% <100.00%> (-0.04%) ⬇️
...fusion/physical-expr/src/aggregate/sum_distinct.rs 92.72% <100.00%> (ø)
datafusion/physical-expr/src/aggregate/tdigest.rs 91.25% <100.00%> (-0.06%) ⬇️
datafusion/proto/src/lib.rs 93.30% <100.00%> (-0.17%) ⬇️
datafusion/expr/src/window_frame.rs 92.43% <0.00%> (-0.85%) ⬇️
datafusion/expr/src/logical_plan/plan.rs 77.43% <0.00%> (-0.35%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@alamb alamb marked this pull request as ready for review August 19, 2022 10:14
Copy link
Member

@xudong963 xudong963 left a comment

Choose a reason for hiding this comment

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

Great simplify 💯

@alamb
Copy link
Contributor Author

alamb commented Aug 20, 2022

Thanks for the review @xudong963

@alamb alamb merged commit e0a9fa3 into apache:master Aug 20, 2022
@ursabot
Copy link

ursabot commented Aug 20, 2022

Benchmark runs are scheduled for baseline = 3df9f80 and contender = e0a9fa3. e0a9fa3 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

@alamb alamb deleted the alamb/cleaner_list branch August 8, 2023 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
physical-expr Physical Expressions sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants