zeroshade commented on code in PR #414:
URL: https://github.com/apache/iceberg-go/pull/414#discussion_r2080224366


##########
catalog/sql/sql.go:
##########
@@ -844,3 +871,235 @@ 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)
+       }
+
+       viewVersion := struct {
+               VersionID       int64             `json:"version-id"`
+               TimestampMs     int64             `json:"timestamp-ms"`
+               SchemaID        int               `json:"schema-id"`
+               Summary         map[string]string `json:"summary"`
+               Representations []struct {
+                       Type    string `json:"type"`
+                       SQL     string `json:"sql"`
+                       Dialect string `json:"dialect"`
+               } `json:"representations"`
+               DefaultCatalog   string   `json:"default-catalog"`

Review Comment:
   this is optional, so let's add `,omitempty` to it



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

Reply via email to