Skip to content

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

Merged
alamb merged 2 commits into
apache:masterfrom
alamb:alamb/cleaner_list
Aug 20, 2022
Merged

[Minor] Reduce code duplication creating ScalarValue::List#3197
alamb merged 2 commits into
apache:masterfrom
alamb:alamb/cleaner_list

Conversation

@alamb

Copy link
Copy Markdown
Contributor

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-actionsgithub-actionsBot added physical-expr Changes to the physical-expr crates 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
Copy Markdown
ContributorAuthor

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

}

/// 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
Copy Markdown
ContributorAuthor

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
Copy Markdown

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 FilesCoverage Δ
datafusion/sql/src/planner.rs81.30% <50.00%> (+0.05%)⬆️
.../physical-expr/src/aggregate/array_agg_distinct.rs79.41% <89.47%> (-0.78%)⬇️
datafusion/common/src/scalar.rs84.65% <100.00%> (-0.10%)⬇️
...atafusion/physical-expr/src/aggregate/array_agg.rs95.74% <100.00%> (-0.18%)⬇️
...sion/physical-expr/src/aggregate/count_distinct.rs95.00% <100.00%> (-0.04%)⬇️
...fusion/physical-expr/src/aggregate/sum_distinct.rs92.72% <100.00%> (ø)
datafusion/physical-expr/src/aggregate/tdigest.rs91.25% <100.00%> (-0.06%)⬇️
datafusion/proto/src/lib.rs93.30% <100.00%> (-0.17%)⬇️
datafusion/expr/src/window_frame.rs92.43% <0.00%> (-0.85%)⬇️
datafusion/expr/src/logical_plan/plan.rs77.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

@xudong963xudong963 left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
ContributorAuthor

Thanks for the review @xudong963

@alamb
alamb merged commit e0a9fa3 into apache:masterAug 20, 2022
@ursabot

Copy link
Copy Markdown

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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-exprChanges to the physical-expr cratessqlSQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@alamb@codecov-commenter@ursabot@xudong963