twuebi commented on code in PR #594:
URL: https://github.com/apache/iceberg-go/pull/594#discussion_r2413472977
##########
types.go:
##########
@@ -677,32 +701,77 @@ func (BinaryType) primitive() {}
func (BinaryType) Type() string { return "binary" }
func (BinaryType) String() string { return "binary" }
+// TimestampNsType represents a timestamp stored as nanoseconds since the unix
epoch
+// without regard for timezone. Requires format version 3+.
+type TimestampNsType struct{}
+
+func (TimestampNsType) Equals(other Type) bool {
+ _, ok := other.(TimestampNsType)
+
+ return ok
+}
+
+func (TimestampNsType) primitive() {}
+func (TimestampNsType) Type() string { return "timestamp_ns" }
+func (TimestampNsType) String() string { return "timestamp_ns" }
+
+// TimestampTzNsType represents a timestamp stored as UTC with nanoseconds
since
+// the unix epoch. Requires format version 3+.
+type TimestampTzNsType struct{}
+
+func (TimestampTzNsType) Equals(other Type) bool {
+ _, ok := other.(TimestampTzNsType)
+
+ return ok
+}
+
+func (TimestampTzNsType) primitive() {}
+func (TimestampTzNsType) Type() string { return "timestamptz_ns" }
+func (TimestampTzNsType) String() string { return "timestamptz_ns" }
+
var PrimitiveTypes = struct {
- Bool PrimitiveType
- Int32 PrimitiveType
- Int64 PrimitiveType
- Float32 PrimitiveType
- Float64 PrimitiveType
- Date PrimitiveType
- Time PrimitiveType
- Timestamp PrimitiveType
- TimestampTz PrimitiveType
- String PrimitiveType
- Binary PrimitiveType
- UUID PrimitiveType
+ Bool PrimitiveType
+ Int32 PrimitiveType
+ Int64 PrimitiveType
+ Float32 PrimitiveType
+ Float64 PrimitiveType
+ Date PrimitiveType
+ Time PrimitiveType
+ Timestamp PrimitiveType
+ TimestampTz PrimitiveType
+ TimestampNs PrimitiveType
+ TimestampTzNs PrimitiveType
+ String PrimitiveType
+ Binary PrimitiveType
+ UUID PrimitiveType
}{
- Bool: BooleanType{},
- Int32: Int32Type{},
- Int64: Int64Type{},
- Float32: Float32Type{},
- Float64: Float64Type{},
- Date: DateType{},
- Time: TimeType{},
- Timestamp: TimestampType{},
- TimestampTz: TimestampTzType{},
- String: StringType{},
- Binary: BinaryType{},
- UUID: UUIDType{},
+ Bool: BooleanType{},
+ Int32: Int32Type{},
+ Int64: Int64Type{},
+ Float32: Float32Type{},
+ Float64: Float64Type{},
+ Date: DateType{},
+ Time: TimeType{},
+ Timestamp: TimestampType{},
+ TimestampTz: TimestampTzType{},
+ TimestampNs: TimestampNsType{},
+ TimestampTzNs: TimestampTzNsType{},
+ String: StringType{},
+ Binary: BinaryType{},
+ UUID: UUIDType{},
+}
+
+// MinFormatVersionForType returns the minimum table format version required
+// for the given type. Returns 1 for types supported in all versions, or a
higher
+// version number for types that require newer format versions.
+func MinFormatVersionForType(t Type) int {
+ switch t.(type) {
+ case TimestampNsType, TimestampTzNsType:
+ return 3
+ default:
+ // All other types supported in v1+
+ return 1
+ }
Review Comment:
I prefer the single source style here, IMO a style question
--
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]