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


##########
catalog/rest.go:
##########
@@ -663,18 +631,40 @@ func splitIdentForPath(ident table.Identifier) (string, 
string, error) {
        return strings.Join(NamespaceFromIdent(ident), namespaceSeparator), 
TableNameFromIdent(ident), nil
 }
 
-func (r *RestCatalog) CreateTable(ctx context.Context, identifier 
table.Identifier, schema *iceberg.Schema, opts ...createTableOption) 
(*table.Table, error) {
+func (r *RestCatalog) CreateTable(ctx context.Context, identifier 
table.Identifier, schema *iceberg.Schema, opts ...createTableOpt) 
(*table.Table, error) {
        ns, tbl, err := splitIdentForPath(identifier)
        if err != nil {
                return nil, err
        }
 
-       payload := createTableRequest{
-               Name:   tbl,
-               Schema: schema,
-       }
+       var cfg createTableCfg
        for _, o := range opts {
-               o(&payload)
+               o(&cfg)
+       }
+
+       freshSchema, err := iceberg.AssignFreshSchemaIDs(schema, nil)
+       if err != nil {
+               return nil, err
+       }
+
+       freshPartitionSpec, err := 
iceberg.AssignFreshPartitionSpecIDs(cfg.partitionSpec, schema, freshSchema)
+       if err != nil {
+               return nil, err
+       }
+
+       freshSortOrder, err := table.AssignFreshSortOrderIDs(cfg.sortOrder, 
schema, freshSchema)
+       if err != nil {
+               return nil, err
+       }
+
+       payload := createTableRequest{
+               Name:          tbl,
+               Schema:        freshSchema,
+               Location:      cfg.location,
+               PartitionSpec: &freshPartitionSpec,
+               WriteOrder:    &freshSortOrder,
+               StageCreate:   false,

Review Comment:
   Looking at pyiceberg: 
https://github.com/apache/iceberg-python/blob/main/pyiceberg/catalog/rest.py#L621
 it's always set to False for `CreateTable`, and set to True for 
`CreateTableTransaction` which we haven't implemented yet.



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