@@ -1101,26 +1101,27 @@ impl GlueService {
11011101 if db. tables . contains_key ( & name) {
11021102 return Err ( already_exists ( format ! ( "Table {name} already exists" ) ) ) ;
11031103 }
1104- db. tables . insert (
1105- name. clone ( ) ,
1106- Table {
1107- name,
1108- database_name : db_name,
1109- description : input[ "Description" ] . as_str ( ) . map ( |s| s. to_string ( ) ) ,
1110- owner : input[ "Owner" ] . as_str ( ) . map ( |s| s. to_string ( ) ) ,
1111- create_time : now,
1112- update_time : now,
1113- last_access_time : None ,
1114- retention : input[ "Retention" ] . as_i64 ( ) . unwrap_or ( 0 ) ,
1115- storage_descriptor : parse_storage_descriptor ( & input[ "StorageDescriptor" ] ) ,
1116- partition_keys : parse_columns ( & input[ "PartitionKeys" ] ) ,
1117- view_original_text : input[ "ViewOriginalText" ] . as_str ( ) . map ( |s| s. to_string ( ) ) ,
1118- view_expanded_text : input[ "ViewExpandedText" ] . as_str ( ) . map ( |s| s. to_string ( ) ) ,
1119- table_type : input[ "TableType" ] . as_str ( ) . map ( |s| s. to_string ( ) ) ,
1120- parameters : parse_string_map ( & input[ "Parameters" ] ) ,
1121- partitions : BTreeMap :: new ( ) ,
1122- } ,
1123- ) ;
1104+ let table = Table {
1105+ name : name. clone ( ) ,
1106+ database_name : db_name. clone ( ) ,
1107+ description : input[ "Description" ] . as_str ( ) . map ( |s| s. to_string ( ) ) ,
1108+ owner : input[ "Owner" ] . as_str ( ) . map ( |s| s. to_string ( ) ) ,
1109+ create_time : now,
1110+ update_time : now,
1111+ last_access_time : None ,
1112+ retention : input[ "Retention" ] . as_i64 ( ) . unwrap_or ( 0 ) ,
1113+ storage_descriptor : parse_storage_descriptor ( & input[ "StorageDescriptor" ] ) ,
1114+ partition_keys : parse_columns ( & input[ "PartitionKeys" ] ) ,
1115+ view_original_text : input[ "ViewOriginalText" ] . as_str ( ) . map ( |s| s. to_string ( ) ) ,
1116+ view_expanded_text : input[ "ViewExpandedText" ] . as_str ( ) . map ( |s| s. to_string ( ) ) ,
1117+ table_type : input[ "TableType" ] . as_str ( ) . map ( |s| s. to_string ( ) ) ,
1118+ parameters : parse_string_map ( & input[ "Parameters" ] ) ,
1119+ partitions : BTreeMap :: new ( ) ,
1120+ } ;
1121+ let tv_json = table_json ( & table) ;
1122+ db. tables . insert ( name. clone ( ) , table) ;
1123+ // Archive the initial version so GetTableVersion(s) return real data.
1124+ state. archive_table_version ( & db_name, & name, tv_json) ;
11241125 Ok ( AwsResponse :: ok_json ( json ! ( { } ) ) )
11251126 }
11261127
@@ -1224,6 +1225,10 @@ impl GlueService {
12241225 if let Some ( r) = input[ "Retention" ] . as_i64 ( ) {
12251226 t. retention = r;
12261227 }
1228+ // Snapshot the mutated table as a new archived version (Glue bumps the
1229+ // VersionId on every UpdateTable).
1230+ let tv_json = table_json ( t) ;
1231+ state. archive_table_version ( db_name, name, tv_json) ;
12271232 Ok ( AwsResponse :: ok_json ( json ! ( { } ) ) )
12281233 }
12291234
@@ -1242,6 +1247,7 @@ impl GlueService {
12421247 if db. tables . remove ( name) . is_none ( ) {
12431248 return Err ( entity_not_found ( format ! ( "Table {name} not found" ) ) ) ;
12441249 }
1250+ state. purge_table_versions ( db_name, name) ;
12451251 Ok ( AwsResponse :: ok_json ( json ! ( { } ) ) )
12461252 }
12471253
0 commit comments