lidavidm commented on a change in pull request #11328:
URL: https://github.com/apache/arrow/pull/11328#discussion_r745851528
##########
File path: cpp/src/arrow/compute/kernels/scalar_cast_test.cc
##########
@@ -1553,8 +1553,77 @@ TEST(Cast, TimestampToString) {
CheckCast(
ArrayFromJSON(timestamp(TimeUnit::SECOND), "[-30610224000,
-5364662400]"),
ArrayFromJSON(string_type, R"(["1000-01-01 00:00:00", "1800-01-01
00:00:00"])"));
+
+ CheckCast(
+ ArrayFromJSON(timestamp(TimeUnit::MILLI), "[-30610224000000,
-5364662400000]"),
+ ArrayFromJSON(string_type,
+ R"(["1000-01-01 00:00:00.000", "1800-01-01
00:00:00.000"])"));
+
+ CheckCast(
+ ArrayFromJSON(timestamp(TimeUnit::MICRO),
+ "[-30610224000000000, -5364662400000000]"),
+ ArrayFromJSON(string_type,
+ R"(["1000-01-01 00:00:00.000000", "1800-01-01
00:00:00.000000"])"));
+
+ CheckCast(
+ ArrayFromJSON(timestamp(TimeUnit::NANO),
+ "[-596933876543210988, 349837323456789012]"),
+ ArrayFromJSON(
+ string_type,
+ R"(["1951-02-01 01:02:03.456789012", "1981-02-01
01:02:03.456789012"])"));
+ }
+}
+
+#ifndef _WIN32
+TEST(Cast, TimestampWithZoneToString) {
+ for (auto string_type : {utf8(), large_utf8()}) {
+ CheckCast(
+ ArrayFromJSON(timestamp(TimeUnit::SECOND, "UTC"), "[-30610224000,
-5364662400]"),
+ ArrayFromJSON(string_type,
+ R"(["1000-01-01 00:00:00Z", "1800-01-01 00:00:00Z"])"));
+
+ CheckCast(
+ ArrayFromJSON(timestamp(TimeUnit::SECOND, "America/Phoenix"),
+ "[-34226955, 1456767743]"),
+ ArrayFromJSON(string_type,
+ R"(["1968-11-30 13:30:45-0700", "2016-02-29
10:42:23-0700"])"));
+
+ CheckCast(ArrayFromJSON(timestamp(TimeUnit::MILLI, "America/Phoenix"),
+ "[-34226955877, 1456767743456]"),
+ ArrayFromJSON(
+ string_type,
+ R"(["1968-11-30 13:30:44.123-0700", "2016-02-29
10:42:23.456-0700"])"));
+
+ CheckCast(
+ ArrayFromJSON(timestamp(TimeUnit::MICRO, "America/Phoenix"),
+ "[-34226955877000, 1456767743456789]"),
+ ArrayFromJSON(
+ string_type,
+ R"(["1968-11-30 13:30:44.123000-0700", "2016-02-29
10:42:23.456789-0700"])"));
+
+ CheckCast(
+ ArrayFromJSON(timestamp(TimeUnit::NANO, "America/Phoenix"),
+ "[-34226955876543211, 1456767743456789246]"),
+ ArrayFromJSON(
+ string_type,
+ R"(["1968-11-30 13:30:44.123456789-0700", "2016-02-29
10:42:23.456789246-0700"])"));
}
}
+#else
+// TODO(ARROW-13168): we lack tzdb on Windows
+TEST(Cast, TimestampWithZoneToString) {
+ for (auto string_type : {utf8(), large_utf8()}) {
+ ASSERT_RAISES(NotImplemented,
Cast(ArrayFromJSON(timestamp(TimeUnit::SECOND, "UTC"),
+ "[-34226955,
1456767743]"),
+ CastOptions::Safe(string_type)));
Review comment:
Filed ARROW-14643.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]