wgtmac commented on code in PR #1157:
URL: https://github.com/apache/iceberg-cpp/pull/1157#discussion_r4664178506


##########
src/iceberg/util/conversions.cc:
##########
@@ -158,20 +160,24 @@ Result<Literal::Value> Conversions::FromBytes(const 
PrimitiveType& type,
       return Literal::Value{value};
     }
     case TypeId::kLong:
-    case TypeId::kTime:
     case TypeId::kTimestamp:
-    case TypeId::kTimestampTz:
     case TypeId::kTimestampNs:
-    case TypeId::kTimestampTzNs: {
-      int64_t value;
-      if (data.size() < 8) {
-        // Type was promoted from int to long
-        ICEBERG_ASSIGN_OR_RAISE(auto int_value, 
ReadLittleEndian<int32_t>(data));
-        value = static_cast<int64_t>(int_value);
-      } else {
-        ICEBERG_ASSIGN_OR_RAISE(auto long_value, 
ReadLittleEndian<int64_t>(data));
-        value = long_value;
+      if (data.size() == sizeof(int32_t)) {
+        ICEBERG_ASSIGN_OR_RAISE(auto value, ReadLittleEndian<int32_t>(data));
+        if (type_id == TypeId::kLong) {
+          return Literal::Value{static_cast<int64_t>(value)};
+        }
+        // Before date promotion, bounds were stored as days since the epoch.
+        const auto units_per_day = type_id == TypeId::kTimestamp ? 
internal::kMicrosPerDay
+                                                                 : 
internal::kNanosPerDay;
+        ICEBERG_ASSIGN_OR_RAISE(auto timestamp, MultiplyExact(value, 
units_per_day));

Review Comment:
   A file containing only epoch day 0 can have a valid loose date upper bound 
of day 106752. After promotion to `timestamp_ns`, the row is still 
representable, but `MultiplyExact` rejects the upper bound and aborts planning. 
Could we treat this bound as unknown while retaining overflow errors for actual 
row values?



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to