alessandro-nori commented on code in PR #629:
URL: https://github.com/apache/iceberg-go/pull/629#discussion_r2541936246
##########
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"`
Review Comment:
`properties` is marked as required field in the spec so we should remove the
`omitempty`
https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml#L3556-L3560
##########
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:
since `Version` is now coming from the caller, I think we should enforce
that fields like VersionID, TimestampMs are correctly set before the request is
sent to the server.
Alternatively we could change the method signature to receive a slice of
`Representation`s instead of `view.Version`
--
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]