lidavidm commented on a change in pull request #10870:
URL: https://github.com/apache/arrow/pull/10870#discussion_r683533457
##########
File path: cpp/src/arrow/compute/kernels/scalar_cast_test.cc
##########
@@ -1208,6 +1215,15 @@ TEST(Cast, TimeZeroCopy) {
time64(TimeUnit::MICRO));
}
+TEST(Cast, DateToString) {
+ for (auto string_type : {utf8(), large_utf8()}) {
+ CheckCast(ArrayFromJSON(date32(), "[0, null]"),
+ ArrayFromJSON(string_type, R"(["1970-01-01", null])"));
+ CheckCast(ArrayFromJSON(date64(), "[86400000, null]"),
+ ArrayFromJSON(string_type, R"(["1970-01-02", null])"));
+ }
+}
+
Review comment:
Since we're adding timestamp support, can we also have a test like this
for timestamps? There's other tests for timestamps around L1066.
##########
File path: cpp/src/arrow/compute/kernels/scalar_cast_test.cc
##########
@@ -208,6 +207,14 @@ TEST(Cast, CanCast) {
ExpectCanCast(smallint(),
kNumericTypes); // any cast which is valid for storage is
supported
ExpectCannotCast(null(), {smallint()}); // FIXME missing common cast from
null
+
+ ExpectCanCast(date32(), {utf8(), large_utf8()});
+ ExpectCanCast(date64(), {utf8(), large_utf8()});
+ ExpectCanCast(timestamp(TimeUnit::NANO), {utf8(), large_utf8()});
+ ExpectCanCast(timestamp(TimeUnit::MICRO), {utf8(), large_utf8()});
+ ExpectCanCast(time32(TimeUnit::MILLI), {utf8(), large_utf8()});
+ ExpectCanCast(time64(TimeUnit::NANO), {utf8(), large_utf8()});
+ //ExpectCanCast(duration(TimeUnit::SECOND), {utf8(), large_utf8()}); //FIXME
Review comment:
This is because TemporalTypes() above is only date, time, and timestamp
types, not durations or intervals:
https://github.com/apache/arrow/blob/af7588344c3fe59a69e02b6f5203e7b7ae06addf/cpp/src/arrow/compute/kernels/codegen_internal.cc#L83-L93
You'll have to register those separately. There's a helper for interval
types, at least:
https://github.com/apache/arrow/blob/af7588344c3fe59a69e02b6f5203e7b7ae06addf/cpp/src/arrow/compute/kernels/codegen_internal.cc#L164-L167
--
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]