pitrou commented on a change in pull request #10988:
URL: https://github.com/apache/arrow/pull/10988#discussion_r699104892
##########
File path: cpp/src/arrow/pretty_print.cc
##########
@@ -421,10 +471,14 @@ class ArrayPrinter : public PrettyPrinter {
private:
template <typename Unit>
void FormatDateTime(const char* fmt, int64_t value, bool add_epoch) {
- if (add_epoch) {
- (*sink_) << arrow_vendored::date::format(fmt, epoch_ + Unit{value});
- } else {
- (*sink_) << arrow_vendored::date::format(fmt, Unit{value});
+ try {
+ if (add_epoch) {
+ (*sink_) << arrow_vendored::date::format(fmt, epoch_ + Unit{value});
Review comment:
Hmm... nice idea, but it unfortunately overflows for nanoseconds.
```
/home/antoine/arrow/dev/cpp/src/arrow/pretty_print.cc: In instantiation of
'void arrow::{anonymous}::ArrayPrinter::FormatDateTime(const char*, int64_t,
bool) [with Unit = std::chrono::duration<long int, std::ratio<1, 1000000000> >;
int64_t = long int]':
/home/antoine/arrow/dev/cpp/src/arrow/pretty_print.cc:505:71: required
from here
/home/antoine/arrow/dev/cpp/src/arrow/pretty_print.cc:483:59: in
'constexpr' expansion of 'std::chrono::duration_cast<std::chrono::duration<long
int, std::ratio<1, 1000000000> >, int, std::ratio<86400, 1>
>(std::chrono::duration<int, std::ratio<86400, 1> >(-12687428))'
/usr/include/c++/9/chrono:200:21: in 'constexpr' expansion of
'std::chrono::__duration_cast_impl<std::chrono::duration<long int,
std::ratio<1, 1000000000> >, std::ratio<86400000000000, 1>, long int, false,
true>::__cast<int, std::ratio<86400, 1> >((* & __d))'
/home/antoine/arrow/dev/cpp/src/arrow/pretty_print.cc:483:20: error:
overflow in constant expression [-fpermissive]
483 | constexpr Unit kMin =
std::chrono::duration_cast<Unit>(arrow_vendored::date::days{-12687428});
| ^~~~
```
--
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]