@@ -22,7 +22,6 @@ use aws_sdk_glue::config::Credentials;
2222use aws_sdk_glue:: types:: { Database , DatabaseInput , StorageDescriptor , TableInput } ;
2323use iceberg:: spec:: TableMetadata ;
2424use iceberg:: { Error , ErrorKind , Namespace , NamespaceIdent , Result } ;
25- use uuid:: Uuid ;
2625
2726use crate :: error:: from_aws_build_error;
2827use crate :: schema:: GlueSchemaBuilder ;
@@ -228,30 +227,6 @@ pub(crate) fn get_default_table_location(
228227 }
229228}
230229
231- /// Create metadata location from `location` and `version`
232- pub ( crate ) fn create_metadata_location ( location : impl AsRef < str > , version : i32 ) -> Result < String > {
233- if version < 0 {
234- return Err ( Error :: new (
235- ErrorKind :: DataInvalid ,
236- format ! (
237- "Table metadata version: '{}' must be a non-negative integer" ,
238- version
239- ) ,
240- ) ) ;
241- } ;
242-
243- let version = format ! ( "{:0>5}" , version) ;
244- let id = Uuid :: new_v4 ( ) ;
245- let metadata_location = format ! (
246- "{}/metadata/{}-{}.metadata.json" ,
247- location. as_ref( ) ,
248- version,
249- id
250- ) ;
251-
252- Ok ( metadata_location)
253- }
254-
255230/// Get metadata location from `GlueTable` parameters
256231pub ( crate ) fn get_metadata_location (
257232 parameters : & Option < HashMap < String , String > > ,
@@ -288,7 +263,7 @@ mod tests {
288263 use aws_sdk_glue:: config:: ProvideCredentials ;
289264 use aws_sdk_glue:: types:: Column ;
290265 use iceberg:: spec:: { NestedField , PrimitiveType , Schema , TableMetadataBuilder , Type } ;
291- use iceberg:: { Namespace , Result , TableCreation } ;
266+ use iceberg:: { MetadataLocation , Namespace , Result , TableCreation } ;
292267
293268 use super :: * ;
294269 use crate :: schema:: { ICEBERG_FIELD_CURRENT , ICEBERG_FIELD_ID , ICEBERG_FIELD_OPTIONAL } ;
@@ -332,7 +307,7 @@ mod tests {
332307 fn test_convert_to_glue_table ( ) -> Result < ( ) > {
333308 let table_name = "my_table" . to_string ( ) ;
334309 let location = "s3a://warehouse/hive" . to_string ( ) ;
335- let metadata_location = create_metadata_location ( location. clone ( ) , 0 ) ? ;
310+ let metadata_location = MetadataLocation :: new_with_table_location ( location) . to_string ( ) ;
336311 let properties = HashMap :: new ( ) ;
337312 let schema = Schema :: builder ( )
338313 . with_schema_id ( 1 )
@@ -372,22 +347,6 @@ mod tests {
372347 Ok ( ( ) )
373348 }
374349
375- #[ test]
376- fn test_create_metadata_location ( ) -> Result < ( ) > {
377- let location = "my_base_location" ;
378- let valid_version = 0 ;
379- let invalid_version = -1 ;
380-
381- let valid_result = create_metadata_location ( location, valid_version) ?;
382- let invalid_result = create_metadata_location ( location, invalid_version) ;
383-
384- assert ! ( valid_result. starts_with( "my_base_location/metadata/00000-" ) ) ;
385- assert ! ( valid_result. ends_with( ".metadata.json" ) ) ;
386- assert ! ( invalid_result. is_err( ) ) ;
387-
388- Ok ( ( ) )
389- }
390-
391350 #[ test]
392351 fn test_get_default_table_location ( ) -> Result < ( ) > {
393352 let properties = HashMap :: from ( [ ( LOCATION . to_string ( ) , "db_location" . to_string ( ) ) ] ) ;
0 commit comments