nastra commented on code in PR #173: URL: https://github.com/apache/iceberg-go/pull/173#discussion_r1804180423
########## catalog/glue.go: ########## @@ -122,33 +149,93 @@ func (c *GlueCatalog) LoadTable(ctx context.Context, identifier table.Identifier return icebergTable, nil } -func (c *GlueCatalog) CatalogType() CatalogType { - return Glue -} - +// DropTable deletes an Iceberg table from the Glue catalog. func (c *GlueCatalog) DropTable(ctx context.Context, identifier table.Identifier) error { - return fmt.Errorf("%w: [Glue Catalog] drop table", iceberg.ErrNotImplemented) + database, tableName, err := identifierToGlueTable(identifier) + if err != nil { + return err + } + + // Check if the table exists and is an Iceberg table. + _, err = c.getTable(ctx, database, tableName) + if err != nil { + return err + } + + params := &glue.DeleteTableInput{ + DatabaseName: aws.String(database), + Name: aws.String(tableName), + } + _, err = c.glueSvc.DeleteTable(ctx, params) + if err != nil { + return fmt.Errorf("failed to drop table %s.%s: %w", database, tableName, err) + } + + return nil } +// RenameTable renames an Iceberg table in the Glue catalog. func (c *GlueCatalog) RenameTable(ctx context.Context, from, to table.Identifier) (*table.Table, error) { - return nil, fmt.Errorf("%w: [Glue Catalog] rename table", iceberg.ErrNotImplemented) -} + fromDatabase, fromTable, err := identifierToGlueTable(from) + if err != nil { + return nil, err + } -func (c *GlueCatalog) CreateNamespace(ctx context.Context, namespace table.Identifier, props iceberg.Properties) error { - return fmt.Errorf("%w: [Glue Catalog] create namespace", iceberg.ErrNotImplemented) -} + toDatabase, toTable, err := identifierToGlueTable(to) + if err != nil { + return nil, err + } -func (c *GlueCatalog) DropNamespace(ctx context.Context, namespace table.Identifier) error { - return fmt.Errorf("%w: [Glue Catalog] drop namespace", iceberg.ErrNotImplemented) -} + if fromDatabase != toDatabase { + return nil, fmt.Errorf("cannot rename table across namespaces: %s -> %s", fromDatabase, toDatabase) + } -func (c *GlueCatalog) LoadNamespaceProperties(ctx context.Context, namespace table.Identifier) (iceberg.Properties, error) { - return nil, fmt.Errorf("%w: [Glue Catalog] load namespace properties", iceberg.ErrNotImplemented) -} + // Fetch the existing Glue table to copy the metadata into the new table. + fromGlueTable, err := c.getTable(ctx, fromDatabase, fromTable) + if err != nil { + return nil, fmt.Errorf("failed to fetch the table %s.%s: %w", fromDatabase, fromTable, err) + } -func (c *GlueCatalog) UpdateNamespaceProperties(ctx context.Context, namespace table.Identifier, - removals []string, updates iceberg.Properties) (PropertiesUpdateSummary, error) { - return PropertiesUpdateSummary{}, fmt.Errorf("%w: [Glue Catalog] update namespace properties", iceberg.ErrNotImplemented) + // Create the new table. + _, err = c.glueSvc.CreateTable(ctx, &glue.CreateTableInput{ Review Comment: I believe this is also missing the glue catalog id? -- 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