File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-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>
25+ // #include <iceberg/result.h>
2426
2527#include " iceberg/exception.h"
2628
2729namespace iceberg {
2830
2931namespace {
3032
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 ));
33+ int32_t MicrosToDays ( int64_t micros_since_epoch) {
34+ std::chrono::microseconds micros (micros_since_epoch);
35+ auto days_duration = std::chrono::floor<std::chrono::days>( micros);
36+ return static_cast <int32_t >(days_duration. count ( ));
3537}
3638
3739} // namespace
@@ -178,7 +180,7 @@ Result<Literal> LiteralCaster::CastFromDouble(
178180 if (double_val > static_cast <double >(std::numeric_limits<float >::max ())) {
179181 return AboveMaxLiteral (target_type);
180182 }
181- if (double_val < - static_cast <double >(std::numeric_limits<float >::max ())) {
183+ if (double_val < static_cast <double >(std::numeric_limits<float >::lowest ())) {
182184 return BelowMinLiteral (target_type);
183185 }
184186 return Literal::Float (static_cast <float >(double_val));
@@ -488,7 +490,7 @@ std::string Literal::ToString() const {
488490 }
489491 case TypeId::kDecimal :
490492 case TypeId::kUuid : {
491- throw IcebergError ( " Not implemented: ToString for " + type_-> ToString () );
493+ throw NotImplemented ( " kDecimal and kUuid are not implemented yet " );
492494 }
493495 default : {
494496 throw IcebergError (" Unknown type: " + type_->ToString ());
You can’t perform that action at this time.
0 commit comments