dttung2905 commented on code in PR #414: URL: https://github.com/apache/iceberg-go/pull/414#discussion_r2101167815
########## catalog/sql/sql.go: ########## @@ -809,3 +821,369 @@ func (c *Catalog) UpdateNamespaceProperties(ctx context.Context, namespace table func (c *Catalog) CheckNamespaceExists(ctx context.Context, namespace table.Identifier) (bool, error) { return c.namespaceExists(ctx, strings.Join(namespace, ".")) } + +// CreateView creates a new view in the catalog. +func (c *Catalog) CreateView(ctx context.Context, identifier table.Identifier, schema *iceberg.Schema, viewSQL string, props iceberg.Properties) error { + nsIdent := catalog.NamespaceFromIdent(identifier) + viewIdent := catalog.TableNameFromIdent(identifier) + ns := strings.Join(nsIdent, ".") + + exists, err := c.namespaceExists(ctx, ns) + if err != nil { + return err + } + if !exists { + return fmt.Errorf("%w: %s", catalog.ErrNoSuchNamespace, ns) + } + + exists, err = c.CheckViewExists(ctx, identifier) + if err != nil { + return err + } + if exists { + return fmt.Errorf("%w: %s", catalog.ErrViewAlreadyExists, identifier) + } + + loc, err := internal.ResolveTableLocation(ctx, "", ns, viewIdent, c.props, c.LoadNamespaceProperties) + if err != nil { + return err + } + + timestampMs := time.Now().UnixMilli() + versionId := int64(1) + + viewVersion := struct { Review Comment: Thanks for the sharp eyes. it was indeed missing an `operation` view in the `viewVersion` -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org