You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/12/05 19:54:39 UTC
[PR] Minor: Use ScalarValue::from impl for strings [arrow-datafusion]
alamb opened a new pull request, #8429:
URL: https://github.com/apache/arrow-datafusion/pull/8429
## Which issue does this PR close?
Follow on to https://github.com/apache/arrow-datafusion/pull/8411
## Rationale for this change
Inspired by the commentary on https://github.com/apache/arrow-datafusion/pull/8411 from @viirya and @Dandandan https://github.com/apache/arrow-datafusion/pull/8411#discussion_r1414334754 I took a walk through the code and found quite a few places where we could clean up the construction of `ScalarValue::Utf8`
## What changes are included in this PR?
Use `ScalarValue::from` impl to create `ScalarValue::Utf8` -- this both takes less code and may avoid some copies.
## Are these changes tested?
Covered by existing tests
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Minor: Use `ScalarValue::from` impl for strings [arrow-datafusion]
Posted by "Dandandan (via GitHub)" <gi...@apache.org>.
Dandandan merged PR #8429:
URL: https://github.com/apache/arrow-datafusion/pull/8429
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Minor: Use `ScalarValue::from` impl for strings [arrow-datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #8429:
URL: https://github.com/apache/arrow-datafusion/pull/8429#discussion_r1416208386
##########
datafusion/core/src/datasource/physical_plan/file_scan_config.rs:
##########
@@ -654,15 +654,9 @@ mod tests {
// file_batch is ok here because we kept all the file cols in the projection
file_batch,
&[
- wrap_partition_value_in_dict(ScalarValue::Utf8(Some(
- "2021".to_owned(),
- ))),
- wrap_partition_value_in_dict(ScalarValue::Utf8(Some(
- "10".to_owned(),
- ))),
- wrap_partition_value_in_dict(ScalarValue::Utf8(Some(
- "26".to_owned(),
- ))),
+ wrap_partition_value_in_dict(ScalarValue::from("2021")),
Review Comment:
This looks better and more concise to me. Hopefully by updating the code we'll also make the codebase easier to work with over time too
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Minor: Use `ScalarValue::from` impl for strings [arrow-datafusion]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #8429:
URL: https://github.com/apache/arrow-datafusion/pull/8429#discussion_r1416262663
##########
datafusion/physical-plan/src/joins/cross_join.rs:
##########
@@ -476,12 +476,8 @@ mod tests {
},
ColumnStatistics {
distinct_count: Precision::Exact(1),
- max_value: Precision::Exact(ScalarValue::Utf8(Some(String::from(
- "x",
- )))),
- min_value: Precision::Exact(ScalarValue::Utf8(Some(String::from(
- "a",
- )))),
+ max_value: Precision::Exact(ScalarValue::from("x")),
+ min_value: Precision::Exact(ScalarValue::from("a")),
Review Comment:
Oh, this is one case looking much concise.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org