lliangyu-lin commented on code in PR #410: URL: https://github.com/apache/iceberg-go/pull/410#discussion_r2069428326
########## catalog/glue/glue.go: ########## @@ -231,29 +238,42 @@ func (c *Catalog) CatalogType() catalog.Type { // CreateTable creates a new Iceberg table in the Glue catalog. // AWS Glue will create a new table and a new metadata file in S3 with the format: metadataLocation/metadata/00000-00000-00000-00000-00000.metadata.json. func (c *Catalog) CreateTable(ctx context.Context, identifier table.Identifier, schema *iceberg.Schema, opts ...catalog.CreateTableOpt) (*table.Table, error) { + staged, err := internal.CreateStagedTable(ctx, c.props, c.LoadNamespaceProperties, identifier, schema, opts...) + if err != nil { + return nil, err + } + database, tableName, err := identifierToGlueTable(identifier) if err != nil { return nil, err } - var cfg catalog.CreateTableCfg - for _, opt := range opts { - opt(&cfg) + + wfs, ok := staged.FS().(io.WriteFileIO) + if !ok { + return nil, errors.New("loaded filesystem IO does not support writing") } - if cfg.Location == "" { - return nil, errors.New("metadata location is required for table creation") + + if err := internal.WriteTableMetadata(staged.Metadata(), wfs, staged.MetadataLocation()); err != nil { + return nil, err } - parameters := map[string]string{} - for k, v := range cfg.Properties { - parameters[k] = v + + var tableDescription *string + if desc := staged.Properties().Get("Description", ""); desc != "" { + tableDescription = aws.String(desc) } + tableInput := &types.TableInput{ - Name: aws.String(tableName), - Parameters: parameters, - TableType: aws.String("EXTERNAL_TABLE"), + Name: aws.String(tableName), + Parameters: map[string]string{ + tableTypePropsKey: glueTypeIceberg, + metadataLocationPropsKey: staged.MetadataLocation(), + }, + TableType: aws.String("EXTERNAL_TABLE"), StorageDescriptor: &types.StorageDescriptor{ - Location: aws.String(cfg.Location), - Columns: schemaToGlueColumns(schema), + Location: aws.String(staged.Metadata().Location()), + Columns: schemaToGlueColumns(schema, true), }, + Description: tableDescription, } _, err = c.glueSvc.CreateTable(ctx, &glue.CreateTableInput{ Review Comment: Found the issue why glue is complaining about table type and metadata location. The block below is not needed for create table and needs to be removed. ``` OpenTableFormatInput: &types.OpenTableFormatInput{ IcebergInput: &types.IcebergInput{ MetadataOperation: types.MetadataOperationCreate, }, }, ``` Tested locally that once this is removed, create table is working correctly. -- 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