You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/08/05 13:20:20 UTC
[GitHub] [arrow-rs] sum12 opened a new pull request #664: Allow casting Timestamp arrays into String
sum12 opened a new pull request #664:
URL: https://github.com/apache/arrow-rs/pull/664
# Which issue does this PR close?
<!---
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #587
# Rationale for this change
<!---
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
there are two commits included in the PR
the first commit shows how it should be possible to implement. But the commit fails to compile with
```rust
error[E0599]: the method `value_as_datetime` exists for reference `&array_primitive::PrimitiveArray<T>`, but its trait bounds were not satisfied
--> arrow/src/compute/kernels/cast.rs:1044:48
|
1044 | (0..array.len()).for_each(|ix| match array.value_as_datetime(ix) {
| ^^^^^^^^^^^^^^^^^ method cannot be called on `&array_primitive::PrimitiveArray<T>` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`T: numeric::ArrowNumericType`
error[E0599]: the method `value_as_datetime` exists for reference `&array_primitive::PrimitiveArray<T>`, but its trait bounds were not satisfied
--> arrow/src/compute/kernels/cast.rs:1044:48
|
1044 | (0..array.len()).for_each(|ix| match array.value_as_datetime(ix) {
| ^^^^^^^^^^^^^^^^^ method cannot be called on `&array_primitive::PrimitiveArray<T>` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`T: numeric::ArrowNumericType`
error: aborting due to previous error
```
and compiles fine with second commit. But it feels not correct to use the second commit as the `ArrowNumericType` and Timestamp* types are not really releated. (Or I do not understand them correctly)
<!---
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
# Are there any user-facing changes?
yes (additional ways to cast array) (where do I document this ?)
no breaking 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 `breaking 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
[GitHub] [arrow-rs] alamb commented on pull request #664: Allow casting Timestamp arrays into String
Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #664:
URL: https://github.com/apache/arrow-rs/pull/664#issuecomment-894516582
Thanks @sum12 -- I plan to check this out tomorrow
--
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
[GitHub] [arrow-rs] alamb commented on a change in pull request #664: Allow casting Timestamp arrays into String
Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #664:
URL: https://github.com/apache/arrow-rs/pull/664#discussion_r685115166
##########
File path: arrow/src/compute/kernels/cast.rs
##########
@@ -1003,6 +1031,26 @@ where
unsafe { PrimitiveArray::<R>::from_trusted_len_iter(iter) }
}
+/// Cast timestamp types to Utf8/LargeUtf8
+fn cast_timestamp_to_string<T, OffsetSize>(array: &ArrayRef) -> Result<ArrayRef>
+where
+ T: ArrowTemporalType + ArrowNumericType,
+ i64: From<<T as ArrowPrimitiveType>::Native>,
+ OffsetSize: StringOffsetSizeTrait,
+{
+ let array = array.as_any().downcast_ref::<PrimitiveArray<T>>().unwrap();
+
+ let mut strvec = Vec::with_capacity(array.len());
+ (0..array.len()).for_each(|ix| match array.value_as_datetime(ix) {
+ Some(ndt) => strvec.push(ndt.to_string()),
+ None => strvec.push("".to_string()),
Review comment:
I think for the `cast` function we should do as @nevi-me suggests and preserve nulls
So `CAST(NULL timestamp)` --> `NULL String`
We can leave the conversion of NULL -> "" as part of the display library
--
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
[GitHub] [arrow-rs] nevi-me commented on a change in pull request #664: Allow casting Timestamp arrays into String
Posted by GitBox <gi...@apache.org>.
nevi-me commented on a change in pull request #664:
URL: https://github.com/apache/arrow-rs/pull/664#discussion_r688300355
##########
File path: arrow/src/compute/kernels/cast.rs
##########
@@ -2171,6 +2224,22 @@ mod tests {
assert!(c.is_null(2));
}
+ #[test]
+ fn test_cast_timestamp_to_string() {
+ let a = TimestampMillisecondArray::from_opt_vec(
+ vec![Some(864000000005), Some(1545696000001), None],
Review comment:
happy that we keep nulls now
--
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
[GitHub] [arrow-rs] codecov-commenter edited a comment on pull request #664: Allow casting Timestamp arrays into String
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #664:
URL: https://github.com/apache/arrow-rs/pull/664#issuecomment-898255995
# [Codecov](https://codecov.io/gh/apache/arrow-rs/pull/664?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#664](https://codecov.io/gh/apache/arrow-rs/pull/664?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d9de2de) into [master](https://codecov.io/gh/apache/arrow-rs/commit/b38a4b6c29ba8b9be02460183c61de86bd9ba7df?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b38a4b6) will **decrease** coverage by `0.04%`.
> The diff coverage is `100.00%`.
[](https://codecov.io/gh/apache/arrow-rs/pull/664?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #664 +/- ##
==========================================
- Coverage 82.50% 82.45% -0.05%
==========================================
Files 168 168
Lines 47237 47379 +142
==========================================
+ Hits 38971 39066 +95
- Misses 8266 8313 +47
```
| [Impacted Files](https://codecov.io/gh/apache/arrow-rs/pull/664?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [arrow/src/compute/kernels/cast.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2NvbXB1dGUva2VybmVscy9jYXN0LnJz) | `94.63% <100.00%> (+0.09%)` | :arrow_up: |
| [arrow/src/array/transform/utils.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L3RyYW5zZm9ybS91dGlscy5ycw==) | `95.00% <0.00%> (-5.00%)` | :arrow_down: |
| [arrow/src/array/equal\_json.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2VxdWFsX2pzb24ucnM=) | `85.21% <0.00%> (-3.48%)` | :arrow_down: |
| [arrow/src/tensor.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL3RlbnNvci5ycw==) | `85.00% <0.00%> (-2.50%)` | :arrow_down: |
| [parquet/src/column/page.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvY29sdW1uL3BhZ2UucnM=) | `97.36% <0.00%> (-1.32%)` | :arrow_down: |
| [arrow/src/array/equal/utils.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2VxdWFsL3V0aWxzLnJz) | `74.00% <0.00%> (-1.00%)` | :arrow_down: |
| [parquet/src/record/api.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvcmVjb3JkL2FwaS5ycw==) | `91.60% <0.00%> (-0.88%)` | :arrow_down: |
| [parquet/src/file/statistics.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvZmlsZS9zdGF0aXN0aWNzLnJz) | `93.80% <0.00%> (-0.83%)` | :arrow_down: |
| [arrow/src/csv/writer.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2Nzdi93cml0ZXIucnM=) | `82.41% <0.00%> (-0.74%)` | :arrow_down: |
| [arrow/src/array/array\_map.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2FycmF5X21hcC5ycw==) | `81.50% <0.00%> (-0.69%)` | :arrow_down: |
| ... and [22 more](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/arrow-rs/pull/664?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/arrow-rs/pull/664?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b38a4b6...d9de2de](https://codecov.io/gh/apache/arrow-rs/pull/664?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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
[GitHub] [arrow-rs] sum12 commented on a change in pull request #664: Allow casting Timestamp arrays into String
Posted by GitBox <gi...@apache.org>.
sum12 commented on a change in pull request #664:
URL: https://github.com/apache/arrow-rs/pull/664#discussion_r684790555
##########
File path: arrow/src/compute/kernels/cast.rs
##########
@@ -1003,6 +1031,26 @@ where
unsafe { PrimitiveArray::<R>::from_trusted_len_iter(iter) }
}
+/// Cast timestamp types to Utf8/LargeUtf8
+fn cast_timestamp_to_string<T, OffsetSize>(array: &ArrayRef) -> Result<ArrayRef>
+where
+ T: ArrowTemporalType + ArrowNumericType,
+ i64: From<<T as ArrowPrimitiveType>::Native>,
+ OffsetSize: StringOffsetSizeTrait,
+{
+ let array = array.as_any().downcast_ref::<PrimitiveArray<T>>().unwrap();
+
+ let mut strvec = Vec::with_capacity(array.len());
+ (0..array.len()).for_each(|ix| match array.value_as_datetime(ix) {
+ Some(ndt) => strvec.push(ndt.to_string()),
+ None => strvec.push("".to_string()),
Review comment:
`array_value_to_string` returns empty strings.
I guess it should be using `cast_options` to preserve `None` and when `cast_options.safe == false` store `ArrowError::CastError` , correct ?
--
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
[GitHub] [arrow-rs] alamb commented on a change in pull request #664: Allow casting Timestamp arrays into String
Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #664:
URL: https://github.com/apache/arrow-rs/pull/664#discussion_r684560200
##########
File path: arrow/src/compute/kernels/cast.rs
##########
@@ -1003,6 +1031,26 @@ where
unsafe { PrimitiveArray::<R>::from_trusted_len_iter(iter) }
}
+/// Cast timestamp types to Utf8/LargeUtf8
+fn cast_timestamp_to_string<T, OffsetSize>(array: &ArrayRef) -> Result<ArrayRef>
+where
+ T: ArrowTemporalType + ArrowNumericType,
+ i64: From<<T as ArrowPrimitiveType>::Native>,
+ OffsetSize: StringOffsetSizeTrait,
+{
+ let array = array.as_any().downcast_ref::<PrimitiveArray<T>>().unwrap();
+
+ let mut strvec = Vec::with_capacity(array.len());
Review comment:
👍
Looks good @sum12 -- thank you so much.
A more Rust idomatic way of doing this might be to do something like
```rust
let strvec = (0..array.len())
.map(|ix| ...)
.collect::<Vec<_>>()
;
```
You might even be able to skip the Vec entirely with something like:
```
let strvec = (0..array.len())
.map(|ix| ...)
.collect::<GenericStringArray<OffsetSize>>()
;
--
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
[GitHub] [arrow-rs] sum12 commented on a change in pull request #664: Allow casting Timestamp arrays into String
Posted by GitBox <gi...@apache.org>.
sum12 commented on a change in pull request #664:
URL: https://github.com/apache/arrow-rs/pull/664#discussion_r688399357
##########
File path: arrow/src/compute/kernels/cast.rs
##########
@@ -1003,6 +1032,30 @@ where
unsafe { PrimitiveArray::<R>::from_trusted_len_iter(iter) }
}
+/// Cast timestamp types to Utf8/LargeUtf8
+fn cast_timestamp_to_string<T, OffsetSize>(array: &ArrayRef) -> Result<ArrayRef>
+where
+ T: ArrowTemporalType + ArrowNumericType,
+ i64: From<<T as ArrowPrimitiveType>::Native>,
+ OffsetSize: StringOffsetSizeTrait,
+{
+ let array = array.as_any().downcast_ref::<PrimitiveArray<T>>().unwrap();
+
+ Ok(Arc::new(
+ (0..array.len())
+ .map(|ix| {
+ if array.is_null(ix) {
+ None
+ } else {
+ array
+ .value_as_datetime(ix)
+ .and_then(|v| Some(v.to_string()))
Review comment:
Clippy did complain. so updated it for that green check mark
--
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
[GitHub] [arrow-rs] alamb commented on a change in pull request #664: Allow casting Timestamp arrays into String
Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #664:
URL: https://github.com/apache/arrow-rs/pull/664#discussion_r685115166
##########
File path: arrow/src/compute/kernels/cast.rs
##########
@@ -1003,6 +1031,26 @@ where
unsafe { PrimitiveArray::<R>::from_trusted_len_iter(iter) }
}
+/// Cast timestamp types to Utf8/LargeUtf8
+fn cast_timestamp_to_string<T, OffsetSize>(array: &ArrayRef) -> Result<ArrayRef>
+where
+ T: ArrowTemporalType + ArrowNumericType,
+ i64: From<<T as ArrowPrimitiveType>::Native>,
+ OffsetSize: StringOffsetSizeTrait,
+{
+ let array = array.as_any().downcast_ref::<PrimitiveArray<T>>().unwrap();
+
+ let mut strvec = Vec::with_capacity(array.len());
+ (0..array.len()).for_each(|ix| match array.value_as_datetime(ix) {
+ Some(ndt) => strvec.push(ndt.to_string()),
+ None => strvec.push("".to_string()),
Review comment:
I think for the `cast` function we should do as @nevi-me suggests and preserve nulls
So `CAST(NULL timestamp)` --> `NULL String`
--
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
[GitHub] [arrow-rs] alamb merged pull request #664: Allow casting Timestamp arrays into String
Posted by GitBox <gi...@apache.org>.
alamb merged pull request #664:
URL: https://github.com/apache/arrow-rs/pull/664
--
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
[GitHub] [arrow-rs] nevi-me commented on a change in pull request #664: Allow casting Timestamp arrays into String
Posted by GitBox <gi...@apache.org>.
nevi-me commented on a change in pull request #664:
URL: https://github.com/apache/arrow-rs/pull/664#discussion_r688300113
##########
File path: arrow/src/compute/kernels/cast.rs
##########
@@ -1003,6 +1032,30 @@ where
unsafe { PrimitiveArray::<R>::from_trusted_len_iter(iter) }
}
+/// Cast timestamp types to Utf8/LargeUtf8
+fn cast_timestamp_to_string<T, OffsetSize>(array: &ArrayRef) -> Result<ArrayRef>
+where
+ T: ArrowTemporalType + ArrowNumericType,
+ i64: From<<T as ArrowPrimitiveType>::Native>,
+ OffsetSize: StringOffsetSizeTrait,
+{
+ let array = array.as_any().downcast_ref::<PrimitiveArray<T>>().unwrap();
+
+ Ok(Arc::new(
+ (0..array.len())
+ .map(|ix| {
+ if array.is_null(ix) {
+ None
+ } else {
+ array
+ .value_as_datetime(ix)
+ .and_then(|v| Some(v.to_string()))
Review comment:
nit: given that your transformation inside `and_then` will always return a valid value, you could have said
```rust
array.value_as_datetime(ix).map(|v| v.to_string())
```
but as it seems like clippy isn't complaining, I'm mainly making this comment for info purposes
--
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
[GitHub] [arrow-rs] codecov-commenter commented on pull request #664: Allow casting Timestamp arrays into String
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #664:
URL: https://github.com/apache/arrow-rs/pull/664#issuecomment-898255995
# [Codecov](https://codecov.io/gh/apache/arrow-rs/pull/664?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#664](https://codecov.io/gh/apache/arrow-rs/pull/664?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (1f996d8) into [master](https://codecov.io/gh/apache/arrow-rs/commit/b38a4b6c29ba8b9be02460183c61de86bd9ba7df?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b38a4b6) will **decrease** coverage by `0.04%`.
> The diff coverage is `100.00%`.
[](https://codecov.io/gh/apache/arrow-rs/pull/664?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #664 +/- ##
==========================================
- Coverage 82.50% 82.45% -0.05%
==========================================
Files 168 168
Lines 47237 47380 +143
==========================================
+ Hits 38971 39067 +96
- Misses 8266 8313 +47
```
| [Impacted Files](https://codecov.io/gh/apache/arrow-rs/pull/664?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [arrow/src/compute/kernels/cast.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2NvbXB1dGUva2VybmVscy9jYXN0LnJz) | `94.63% <100.00%> (+0.09%)` | :arrow_up: |
| [arrow/src/array/transform/utils.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L3RyYW5zZm9ybS91dGlscy5ycw==) | `95.00% <0.00%> (-5.00%)` | :arrow_down: |
| [arrow/src/array/equal\_json.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2VxdWFsX2pzb24ucnM=) | `85.21% <0.00%> (-3.48%)` | :arrow_down: |
| [arrow/src/tensor.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL3RlbnNvci5ycw==) | `85.00% <0.00%> (-2.50%)` | :arrow_down: |
| [parquet/src/column/page.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvY29sdW1uL3BhZ2UucnM=) | `97.36% <0.00%> (-1.32%)` | :arrow_down: |
| [arrow/src/array/equal/utils.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2VxdWFsL3V0aWxzLnJz) | `74.00% <0.00%> (-1.00%)` | :arrow_down: |
| [parquet/src/record/api.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvcmVjb3JkL2FwaS5ycw==) | `91.60% <0.00%> (-0.88%)` | :arrow_down: |
| [parquet/src/file/statistics.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvZmlsZS9zdGF0aXN0aWNzLnJz) | `93.80% <0.00%> (-0.83%)` | :arrow_down: |
| [arrow/src/csv/writer.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2Nzdi93cml0ZXIucnM=) | `82.41% <0.00%> (-0.74%)` | :arrow_down: |
| [arrow/src/array/array\_map.rs](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2FycmF5X21hcC5ycw==) | `81.50% <0.00%> (-0.69%)` | :arrow_down: |
| ... and [22 more](https://codecov.io/gh/apache/arrow-rs/pull/664/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/arrow-rs/pull/664?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/arrow-rs/pull/664?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b38a4b6...1f996d8](https://codecov.io/gh/apache/arrow-rs/pull/664?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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
[GitHub] [arrow-rs] nevi-me commented on a change in pull request #664: Allow casting Timestamp arrays into String
Posted by GitBox <gi...@apache.org>.
nevi-me commented on a change in pull request #664:
URL: https://github.com/apache/arrow-rs/pull/664#discussion_r684768641
##########
File path: arrow/src/compute/kernels/cast.rs
##########
@@ -1003,6 +1031,26 @@ where
unsafe { PrimitiveArray::<R>::from_trusted_len_iter(iter) }
}
+/// Cast timestamp types to Utf8/LargeUtf8
+fn cast_timestamp_to_string<T, OffsetSize>(array: &ArrayRef) -> Result<ArrayRef>
+where
+ T: ArrowTemporalType + ArrowNumericType,
+ i64: From<<T as ArrowPrimitiveType>::Native>,
+ OffsetSize: StringOffsetSizeTrait,
+{
+ let array = array.as_any().downcast_ref::<PrimitiveArray<T>>().unwrap();
+
+ let mut strvec = Vec::with_capacity(array.len());
+ (0..array.len()).for_each(|ix| match array.value_as_datetime(ix) {
+ Some(ndt) => strvec.push(ndt.to_string()),
+ None => strvec.push("".to_string()),
Review comment:
In addition to @alamb's suggestion of not allocating a new vec, this looks like it'd convert nulls to an empty string, thereby losing the null count.
Is this behaviour desirable, or should we preserve nulls?
--
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
[GitHub] [arrow-rs] nevi-me commented on a change in pull request #664: Allow casting Timestamp arrays into String
Posted by GitBox <gi...@apache.org>.
nevi-me commented on a change in pull request #664:
URL: https://github.com/apache/arrow-rs/pull/664#discussion_r688300113
##########
File path: arrow/src/compute/kernels/cast.rs
##########
@@ -1003,6 +1032,30 @@ where
unsafe { PrimitiveArray::<R>::from_trusted_len_iter(iter) }
}
+/// Cast timestamp types to Utf8/LargeUtf8
+fn cast_timestamp_to_string<T, OffsetSize>(array: &ArrayRef) -> Result<ArrayRef>
+where
+ T: ArrowTemporalType + ArrowNumericType,
+ i64: From<<T as ArrowPrimitiveType>::Native>,
+ OffsetSize: StringOffsetSizeTrait,
+{
+ let array = array.as_any().downcast_ref::<PrimitiveArray<T>>().unwrap();
+
+ Ok(Arc::new(
+ (0..array.len())
+ .map(|ix| {
+ if array.is_null(ix) {
+ None
+ } else {
+ array
+ .value_as_datetime(ix)
+ .and_then(|v| Some(v.to_string()))
Review comment:
nit: given that your transformation inside `and_then` will always return a valid value, you could have said
```rust
array.value_as_datetime(ix).map(|v| v.to_string())
```
but we can wait to see if Clippy complains about it, otherwise there's no need to change this
--
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