@@ -22,7 +22,6 @@ use aws_sdk_glue::config::Credentials;
22
22
use aws_sdk_glue:: types:: { Database , DatabaseInput , StorageDescriptor , TableInput } ;
23
23
use iceberg:: spec:: TableMetadata ;
24
24
use iceberg:: { Error , ErrorKind , Namespace , NamespaceIdent , Result } ;
25
- use uuid:: Uuid ;
26
25
27
26
use crate :: error:: from_aws_build_error;
28
27
use crate :: schema:: GlueSchemaBuilder ;
@@ -228,30 +227,6 @@ pub(crate) fn get_default_table_location(
228
227
}
229
228
}
230
229
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
-
255
230
/// Get metadata location from `GlueTable` parameters
256
231
pub ( crate ) fn get_metadata_location (
257
232
parameters : & Option < HashMap < String , String > > ,
@@ -288,7 +263,7 @@ mod tests {
288
263
use aws_sdk_glue:: config:: ProvideCredentials ;
289
264
use aws_sdk_glue:: types:: Column ;
290
265
use iceberg:: spec:: { NestedField , PrimitiveType , Schema , TableMetadataBuilder , Type } ;
291
- use iceberg:: { Namespace , Result , TableCreation } ;
266
+ use iceberg:: { MetadataLocation , Namespace , Result , TableCreation } ;
292
267
293
268
use super :: * ;
294
269
use crate :: schema:: { ICEBERG_FIELD_CURRENT , ICEBERG_FIELD_ID , ICEBERG_FIELD_OPTIONAL } ;
@@ -332,7 +307,7 @@ mod tests {
332
307
fn test_convert_to_glue_table ( ) -> Result < ( ) > {
333
308
let table_name = "my_table" . to_string ( ) ;
334
309
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 ( ) ;
336
311
let properties = HashMap :: new ( ) ;
337
312
let schema = Schema :: builder ( )
338
313
. with_schema_id ( 1 )
@@ -372,22 +347,6 @@ mod tests {
372
347
Ok ( ( ) )
373
348
}
374
349
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
-
391
350
#[ test]
392
351
fn test_get_default_table_location ( ) -> Result < ( ) > {
393
352
let properties = HashMap :: from ( [ ( LOCATION . to_string ( ) , "db_location" . to_string ( ) ) ] ) ;
0 commit comments