File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 1919
2020#include " iceberg/expression/literal.h"
2121
22+ #include < chrono>
2223#include < cmath>
2324#include < concepts>
2425
@@ -28,10 +29,10 @@ namespace iceberg {
2829
2930namespace {
3031
31- constexpr int64_t kMicrosPerDay = 86400000000LL ; // 24 * 60 * 60 * 1000 * 1000
32-
33- int32_t MicrosToDays ( int64_t micros) {
34- return static_cast <int32_t >(std::floor ( static_cast < double >(micros) / kMicrosPerDay ));
32+ int32_t MicrosToDays ( int64_t micros_since_epoch) {
33+ std::chrono::microseconds micros (micros_since_epoch);
34+ auto days_duration = std::chrono::floor<std::chrono::days>( micros);
35+ return static_cast <int32_t >(days_duration. count ( ));
3536}
3637
3738} // namespace
@@ -178,7 +179,7 @@ Result<Literal> LiteralCaster::CastFromDouble(
178179 if (double_val > static_cast <double >(std::numeric_limits<float >::max ())) {
179180 return AboveMaxLiteral (target_type);
180181 }
181- if (double_val < - static_cast <double >(std::numeric_limits<float >::max ())) {
182+ if (double_val < static_cast <double >(std::numeric_limits<float >::lowest ())) {
182183 return BelowMinLiteral (target_type);
183184 }
184185 return Literal::Float (static_cast <float >(double_val));
@@ -488,7 +489,7 @@ std::string Literal::ToString() const {
488489 }
489490 case TypeId::kDecimal :
490491 case TypeId::kUuid : {
491- throw IcebergError ( " Not implemented: ToString for " + type_-> ToString () );
492+ throw NotImplemented ( " kDecimal and kUuid are not implemented yet " );
492493 }
493494 default : {
494495 throw IcebergError (" Unknown type: " + type_->ToString ());
You can’t perform that action at this time.
0 commit comments