alessandro-nori commented on code in PR #629:
URL: https://github.com/apache/iceberg-go/pull/629#discussion_r2542822569


##########
catalog/rest/rest.go:
##########
@@ -1159,55 +1159,95 @@ type createViewRequest struct {
        Schema      *iceberg.Schema    `json:"schema"`
        Location    string             `json:"location,omitempty"`
        Props       iceberg.Properties `json:"properties,omitempty"`
-       SQL         string             `json:"sql"`
-       ViewVersion view.Version       `json:"view-version"`
+       ViewVersion *view.Version      `json:"view-version"`
 }
 
 type viewResponse struct {
        MetadataLoc string             `json:"metadata-location"`
        RawMetadata json.RawMessage    `json:"metadata"`
        Config      iceberg.Properties `json:"config"`
-       Metadata    table.Metadata     `json:"-"`
+       Metadata    view.Metadata      `json:"-"`
+}
+
+func (v *viewResponse) UnmarshalJSON(b []byte) (err error) {
+       type Alias viewResponse
+       if err = json.Unmarshal(b, (*Alias)(v)); err != nil {
+               return err
+       }
+
+       v.Metadata, err = view.ParseMetadataBytes(v.RawMetadata)
+
+       return
 }
 
 // CreateView creates a new view in the catalog.
-func (r *Catalog) CreateView(ctx context.Context, identifier table.Identifier, 
schema *iceberg.Schema, sql string, props iceberg.Properties) error {
-       ns, v, err := splitIdentForPath(identifier)
+func (r *Catalog) CreateView(ctx context.Context, identifier table.Identifier, 
version *view.Version, schema *iceberg.Schema, opts ...catalog.CreateViewOpt) 
(*view.View, error) {
+       ns, viewName, err := splitIdentForPath(identifier)
        if err != nil {
-               return err
+               return nil, err
+       }
+
+       if opts == nil {
+               opts = []catalog.CreateViewOpt{}
+       }
+       cfg := catalog.NewCreateViewCfg()
+       for _, opt := range opts {
+               opt(&cfg)
        }
 
        freshSchema, err := iceberg.AssignFreshSchemaIDs(schema, nil)
        if err != nil {
-               return err
+               return nil, err
+       }
+

Review Comment:
   Makes sense, thanks for the clarification.
   About `Version`, I would be consistent with how `Snapshot` is handled for 
`table.Metadata` so I think the current implementation is fine.



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