piyushsingariya commented on code in PR #240:
URL: https://github.com/apache/iceberg-go/pull/240#discussion_r1899655889


##########
catalog/rest.go:
##########
@@ -710,3 +777,54 @@ func (r *RestCatalog) UpdateNamespaceProperties(ctx 
context.Context, namespace t
        return doPost[payload, PropertiesUpdateSummary](ctx, r.baseURI, 
[]string{"namespaces", ns, "properties"},
                payload{Remove: removals, Updates: updates}, r.cl, 
map[int]error{http.StatusNotFound: ErrNoSuchNamespace})
 }
+
+func (r *RestCatalog) CreateTable(ctx context.Context, identifier 
table.Identifier, schema *iceberg.Schema, 
+       partition iceberg.PartitionSpec, location string, props 
iceberg.Properties) (*table.Table, error) {
+       
+       ns, tbl, err := splitIdentForPath(identifier)
+       if err != nil {
+               return nil, err
+       }

Review Comment:
   ```suggestion
        namespace, table, err := splitIdentifierForPath(identifier)
        if err != nil {
                return nil, err
        }
   ```



##########
catalog/rest.go:
##########
@@ -626,11 +628,76 @@ func (r *RestCatalog) LoadTable(ctx context.Context, 
identifier table.Identifier
 }
 
 func (r *RestCatalog) DropTable(ctx context.Context, identifier 
table.Identifier) error {
-       return fmt.Errorf("%w: [Rest Catalog] drop table", 
iceberg.ErrNotImplemented)
+       ns, tbl, err := splitIdentForPath(identifier)
+       if err != nil {
+               return err
+       }
+
+       _, err = doDelete[struct{}](
+               ctx,
+               r.baseURI,
+               []string{"namespaces", ns, "tables", tbl},
+               r.cl,
+               map[int]error{
+                       http.StatusNotFound: ErrNoSuchTable,
+               },
+       )
+       return err
 }
 
 func (r *RestCatalog) RenameTable(ctx context.Context, from, to 
table.Identifier) (*table.Table, error) {
-       return nil, fmt.Errorf("%w: [Rest Catalog] rename table", 
iceberg.ErrNotImplemented)
+       fromNs, fromTbl, err := splitIdentForPath(from)
+       if err != nil {
+               return nil, err
+       }
+
+       toNs, toTbl, err := splitIdentForPath(to)
+       if err != nil {
+               return nil, err
+       }

Review Comment:
   ```suggestion
        fromNamespace, fromTable, err := splitIdentForPath(from)
        if err != nil {
                return nil, err
        }
   
        toNamespace, toTable, err := splitIdentifierForPath(to)
        if err != nil {
                return nil, err
        }
   ```



##########
catalog/rest.go:
##########
@@ -710,3 +777,54 @@ func (r *RestCatalog) UpdateNamespaceProperties(ctx 
context.Context, namespace t
        return doPost[payload, PropertiesUpdateSummary](ctx, r.baseURI, 
[]string{"namespaces", ns, "properties"},
                payload{Remove: removals, Updates: updates}, r.cl, 
map[int]error{http.StatusNotFound: ErrNoSuchNamespace})
 }
+
+func (r *RestCatalog) CreateTable(ctx context.Context, identifier 
table.Identifier, schema *iceberg.Schema, 
+       partition iceberg.PartitionSpec, location string, props 
iceberg.Properties) (*table.Table, error) {
+       
+       ns, tbl, err := splitIdentForPath(identifier)
+       if err != nil {
+               return nil, err
+       }
+
+       payload := map[string]interface{}{
+               "name": tbl,
+               "location": location,
+               "schema": schema,
+               "partition-spec": partition,
+               "properties": props,
+               "stage-create": false,
+       }
+
+       ret, err := doPost[map[string]interface{}, tblResponse](
+               ctx,
+               r.baseURI,
+               []string{"namespaces", ns, "tables"},
+               payload,
+               r.cl,
+               map[int]error{
+                       http.StatusNotFound: ErrNoSuchNamespace,
+                       http.StatusConflict: ErrTableAlreadyExists,
+               },
+       )
+       if err != nil {
+               return nil, err
+       }
+
+       id := identifier
+       if r.name != "" {
+               id = append([]string{r.name}, identifier...)
+       }
+
+       tblProps := maps.Clone(r.props)

Review Comment:
   ```suggestion
        tableProperties := maps.Clone(r.props)
   ```



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