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: remove some uses of unwrap #6738

Merged
merged 1 commit into from
Jun 21, 2023
Merged

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jun 21, 2023

Which issue does this PR close?

Minor follow on to #6723

Rationale for this change

While reviewing #6723 (thanks @BryanEmond !) I noticed it would be possible to do so with a little less code using Option::map so I coded it up

What changes are included in this PR?

Refactor some code to avoid unwrap

Are these changes tested?

Covered by existing tests added in #6723

Are there any user-facing changes?

@github-actions github-actions bot added the physical-expr Changes to the physical-expr crates label Jun 21, 2023
match granularity.as_str() {
"minute" => {
// trunc to minute
let second = ScalarValue::TimestampNanosecond(
Some(nano.unwrap() / 1_000_000_000 * 1_000_000_000),
nano.map(|nano| nano / 1_000_000_000 * 1_000_000_000),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

since nano is already an option, we can skip the check/unwrap using Option::map

@alamb alamb merged commit b275e1d into apache:main Jun 21, 2023
@alamb
Copy link
Contributor Author

alamb commented Jun 21, 2023

Thanks @viirya

@alamb alamb deleted the alamb/less_unwrap branch June 21, 2023 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
physical-expr Changes to the physical-expr crates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants