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


##########
src/iceberg/util/conversions.cc:
##########
@@ -158,20 +190,27 @@ 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)};
+        }
+        // Only timestamps without a zone can be promoted from a four-byte 
date.
+        // https://iceberg.apache.org/spec/#schema-evolution
+        auto timestamp = PromoteDate(value, type_id);
+        if (!timestamp) {
+          return InvalidArgument("Date {} is outside the range of {}", value,

Review Comment:
   I think promoting an identity-partitioned `date` to `timestamp_ns` is 
disallowed because it changes the partition value. The day, month, and year 
transforms keep the same partition values across the promotion.



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