You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "comphead (via GitHub)" <gi...@apache.org> on 2023/02/07 19:06:16 UTC

[GitHub] [arrow-rs] comphead opened a new pull request, #3673: Support UTF8 cast to Timestamp with timezone

comphead opened a new pull request, #3673:
URL: https://github.com/apache/arrow-rs/pull/3673

   # 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 #3664.
   
   # 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.
   -->
   Support UTF8 cast to TimestampTZ in formats like PG https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME-TIME-TABLE
   
   # What changes are included in this PR?
   <!--
   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?
   No
   
   <!--
   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] comphead commented on pull request #3673: Support UTF8 cast to Timestamp with timezone

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on PR #3673:
URL: https://github.com/apache/arrow-rs/pull/3673#issuecomment-1424433268

   @tustvold @viirya @waitingkuo please take a look until the code rots


-- 
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] viirya commented on a diff in pull request #3673: Support UTF8 cast to Timestamp with timezone

Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #3673:
URL: https://github.com/apache/arrow-rs/pull/3673#discussion_r1099142154


##########
arrow-cast/src/cast.rs:
##########
@@ -168,7 +168,7 @@ pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool {
             | Time32(TimeUnit::Millisecond)
             | Time64(TimeUnit::Microsecond)
             | Time64(TimeUnit::Nanosecond)
-            | Timestamp(TimeUnit::Nanosecond, None)
+            | Timestamp(TimeUnit::Nanosecond, _)
         ) => true,

Review Comment:
   Since you have `*tz == Some("+00:00".to_owned())` as condition, it seems also necessary to put it here. Otherwise there will be casting error because `can_cast_types` reports it is supported. 



-- 
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] ursabot commented on pull request #3673: Support UTF8 cast to Timestamp with timezone

Posted by "ursabot (via GitHub)" <gi...@apache.org>.
ursabot commented on PR #3673:
URL: https://github.com/apache/arrow-rs/pull/3673#issuecomment-1425715695

   Benchmark runs are scheduled for baseline = bb4fc59009e7c5861a6b1967a53e9daa2554d5c6 and contender = 07e20639b7023fcc61c73f80a5bddf8715c2a06f. 07e20639b7023fcc61c73f80a5bddf8715c2a06f is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/5c55241f250d4bd089087a6c71d54af3...fba77e998c0c4a6992ad5111ca308923/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/b568741083994f86a97568385d20e4c7...13a9d355c3c64a5a84432352c21e9438/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/2bc40dd925db4f898b8115e4cfd68d08...8a32612aa20241afb0e7dc2ee97aafc3/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/1b139f4074bf4526b3964d1b95c2cd3c...c152ba2c78c346919fedfa4a68e462ad/)
   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
   


-- 
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] comphead commented on a diff in pull request #3673: Support UTF8 cast to Timestamp with timezone

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #3673:
URL: https://github.com/apache/arrow-rs/pull/3673#discussion_r1099503179


##########
arrow-cast/src/cast.rs:
##########
@@ -168,7 +168,7 @@ pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool {
             | Time32(TimeUnit::Millisecond)
             | Time64(TimeUnit::Microsecond)
             | Time64(TimeUnit::Nanosecond)
-            | Timestamp(TimeUnit::Nanosecond, None)
+            | Timestamp(TimeUnit::Nanosecond, _)
         ) => true,

Review Comment:
   Done



##########
arrow-cast/src/cast.rs:
##########
@@ -7833,4 +7836,41 @@ mod tests {
         assert_eq!(v.value(0), 946728000000);
         assert_eq!(v.value(1), 1608035696000);
     }
+
+    #[test]
+    fn test_cast_utf8_to_timestamp() {
+        let valid = StringArray::from(vec![
+            "2023-01-01 04:05:06.789000-08:00",
+            "2023-01-01 04:05:06.789000-07:00",
+            "2023-01-01 04:05:06.789 -0800",
+            "2023-01-01 04:05:06.789 -08:00",
+            "2023-01-01 040506 +0730",
+            "2023-01-01 040506 +07:30",
+            "2023-01-01 04:05:06.789",
+            "2023-01-01 04:05:06",
+            "2023-01-01",
+        ]);
+
+        let array = Arc::new(valid) as ArrayRef;
+        let b = cast(
+            &array,
+            &DataType::Timestamp(TimeUnit::Nanosecond, Some("+00:00".to_string())),

Review Comment:
   Done



-- 
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] tustvold merged pull request #3673: Support UTF8 cast to Timestamp with timezone

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold merged PR #3673:
URL: https://github.com/apache/arrow-rs/pull/3673


-- 
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] comphead commented on pull request #3673: Support UTF8 cast to Timestamp with timezone

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on PR #3673:
URL: https://github.com/apache/arrow-rs/pull/3673#issuecomment-1421307951

   @waitingkuo @tustvold 


-- 
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] waitingkuo commented on a diff in pull request #3673: Support UTF8 cast to Timestamp with timezone

Posted by "waitingkuo (via GitHub)" <gi...@apache.org>.
waitingkuo commented on code in PR #3673:
URL: https://github.com/apache/arrow-rs/pull/3673#discussion_r1099121331


##########
arrow-cast/src/cast.rs:
##########
@@ -7833,4 +7836,41 @@ mod tests {
         assert_eq!(v.value(0), 946728000000);
         assert_eq!(v.value(1), 1608035696000);
     }
+
+    #[test]
+    fn test_cast_utf8_to_timestamp() {
+        let valid = StringArray::from(vec![
+            "2023-01-01 04:05:06.789000-08:00",
+            "2023-01-01 04:05:06.789000-07:00",
+            "2023-01-01 04:05:06.789 -0800",
+            "2023-01-01 04:05:06.789 -08:00",
+            "2023-01-01 040506 +0730",
+            "2023-01-01 040506 +07:30",
+            "2023-01-01 04:05:06.789",
+            "2023-01-01 04:05:06",
+            "2023-01-01",
+        ]);
+
+        let array = Arc::new(valid) as ArrayRef;
+        let b = cast(
+            &array,
+            &DataType::Timestamp(TimeUnit::Nanosecond, Some("+00:00".to_string())),

Review Comment:
   👍 
   
   it'd be great if we could add some test cases for casting to non-utc time zone



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