@@ -1479,6 +1479,53 @@ func TestGlueRenameTable(t *testing.T) {
14791479 assert .True (testSchema .Equals (renamedTable .Schema ()))
14801480}
14811481
1482+ func TestGlueRenameTable_CreateTableFailureUsesDestinationName (t * testing.T ) {
1483+ assert := require .New (t )
1484+
1485+ mockGluesvc := & mockGlueClient {}
1486+
1487+ mockGluesvc .On ("GetDatabase" , mock .Anything , & glue.GetDatabaseInput {
1488+ Name : aws .String ("new_test_database" ),
1489+ }, mock .Anything ).Return (& glue.GetDatabaseOutput {
1490+ Database : & types.Database {
1491+ Name : aws .String ("new_test_database" ),
1492+ },
1493+ }, nil ).Once ()
1494+
1495+ mockGluesvc .On ("GetTable" , mock .Anything , & glue.GetTableInput {
1496+ DatabaseName : aws .String ("test_database" ),
1497+ Name : aws .String ("test_table" ),
1498+ }, mock .Anything ).Return (& glue.GetTableOutput {
1499+ Table : & types.Table {
1500+ Name : aws .String ("test_table" ),
1501+ TableType : aws .String ("EXTERNAL_TABLE" ),
1502+ VersionId : aws .String ("v1" ),
1503+ Parameters : map [string ]string {
1504+ tableParamTableType : glueTypeIceberg ,
1505+ tableParamMetadataLocation : "s3://test-bucket/test_table/metadata/abvc123-123.metadata.json" ,
1506+ },
1507+ StorageDescriptor : & types.StorageDescriptor {},
1508+ },
1509+ }, nil ).Once ()
1510+
1511+ mockGluesvc .On ("CreateTable" , mock .Anything , mock .Anything , mock .Anything ).
1512+ Return (& glue.CreateTableOutput {}, errors .New ("create table failed" )).Once ()
1513+
1514+ glueCatalog := & Catalog {
1515+ glueSvc : mockGluesvc ,
1516+ }
1517+
1518+ renamedTable , err := glueCatalog .RenameTable (
1519+ context .TODO (),
1520+ TableIdentifier ("test_database" , "test_table" ),
1521+ TableIdentifier ("new_test_database" , "new_test_table" ),
1522+ )
1523+
1524+ assert .ErrorContains (err , "failed to create the table new_test_database.new_test_table" )
1525+ assert .Nil (renamedTable )
1526+ mockGluesvc .AssertExpectations (t )
1527+ }
1528+
14821529func TestGlueRenameTable_DeleteTableFailureRollback (t * testing.T ) {
14831530 assert := require .New (t )
14841531
0 commit comments