rambleraptor commented on code in PR #23:
URL: https://github.com/apache/iceberg-terraform/pull/23#discussion_r2961897591
##########
internal/provider/table_schema.go:
##########
@@ -95,6 +96,105 @@ func (s *icebergTableSchema) FromIceberg(icebergSchema
*iceberg.Schema) error {
return json.Unmarshal(b, s)
}
+type icebergTablePartitionSpec struct {
+ Fields []icebergTablePartitionField `tfsdk:"fields" json:"fields"`
+}
+
+func (s icebergTablePartitionSpec) AttrTypes() map[string]attr.Type {
+ return map[string]attr.Type{
+ "fields": types.ListType{
+ ElemType: types.ObjectType{
+ AttrTypes:
icebergTablePartitionField{}.AttrTypes(),
+ },
+ },
+ }
+}
+
+func (s *icebergTablePartitionSpec) ToIceberg() (*iceberg.PartitionSpec,
error) {
+ b, err := json.Marshal(s)
+ if err != nil {
+ return nil, err
+ }
+ var icebergSpec iceberg.PartitionSpec
+ if err := json.Unmarshal(b, &icebergSpec); err != nil {
+ return nil, err
+ }
+ return &icebergSpec, nil
+}
+
+func (s *icebergTablePartitionSpec) FromIceberg(icebergSpec
iceberg.PartitionSpec) error {
+ b, err := json.Marshal(icebergSpec)
+ if err != nil {
+ return err
+ }
+ return json.Unmarshal(b, s)
+}
+
+type icebergTablePartitionField struct {
+ SourceID int64 `tfsdk:"source_id" json:"source-id"`
+ FieldID int64 `tfsdk:"-" json:"field-id"`
Review Comment:
Originally, I was thinking that we should have Terraform manage the field
IDs for us. But, I'm now thinking those should be user-managed, while the
Partition Spec `spec-id` is managed for us. That's how we handled it for schema.
--
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]