Fokko commented on code in PR #4435:
URL: https://github.com/apache/iceberg-python/pull/4435#discussion_r4771358834


##########
pyiceberg/types.py:
##########
@@ -469,6 +471,11 @@ def __init__(
         data["initial-default"] = data["initial-default"] if "initial-default" 
in data else initial_default
         data["write-default"] = data["write-default"] if "write-default" in 
data else write_default
         super().__init__(**data)
+        self._initial_default_value = self.initial_default
+        if self.initial_default is not None and isinstance(self.field_type, 
(DateType, TimeType, TimestampType, TimestamptzType)):
+            from pyiceberg.expressions.literals import literal
+
+            self._initial_default_value = 
literal(self.initial_default).to(self.field_type).value

Review Comment:
   Checked this locally, dropping the `isinstance` check works. 
`literal(v).to(field_type).value` returns the value unchanged for the 
non-temporal primitives (boolean, int, long, float, double, decimal, string, 
uuid, fixed, binary), and date/time/timestamp/timestamptz still get converted 
to days/micros. The existing tests, plus the new ones in this PR, pass with the 
suggestion applied.
   



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