@@ -344,6 +344,31 @@ func TestAddColumn(t *testing.T) {
344344 }},
345345 }, newSchema .Fields ())
346346 })
347+
348+ t .Run ("test update schema with add geometry and geography columns" , func (t * testing.T ) {
349+ table := New ([]string {"id" }, testMetadata , "" , nil , nil )
350+ txn := table .NewTransaction ()
351+
352+ geog , err := iceberg .GeographyTypeOf ("srid:4269" , iceberg .EdgeAlgorithmKarney )
353+ assert .NoError (t , err )
354+
355+ newSchema , err := NewUpdateSchema (txn , true , true ).
356+ AddColumn ([]string {"geom" }, iceberg.GeometryType {}, "" , false , nil ).
357+ AddColumn ([]string {"geog" }, geog , "" , false , nil ).
358+ Apply ()
359+ assert .NoError (t , err )
360+ assert .NotNil (t , newSchema )
361+
362+ geomField , ok := newSchema .FindFieldByName ("geom" )
363+ assert .True (t , ok )
364+ assert .Equal (t , 12 , geomField .ID )
365+ assert .Equal (t , iceberg.GeometryType {}, geomField .Type )
366+
367+ geogField , ok := newSchema .FindFieldByName ("geog" )
368+ assert .True (t , ok )
369+ assert .Equal (t , 13 , geogField .ID )
370+ assert .True (t , geogField .Type .Equals (geog ))
371+ })
347372}
348373
349374func TestApplyChanges (t * testing.T ) {
@@ -861,6 +886,31 @@ func TestErrorHandling(t *testing.T) {
861886 assert .Contains (t , err .Error (), "cannot change column nullability from optional to required" )
862887 })
863888
889+ t .Run ("test update geography CRS and edge algorithm without allowIncompatibleChanges" , func (t * testing.T ) {
890+ currentGeog , err := iceberg .GeographyTypeOf ("srid:4269" , iceberg .EdgeAlgorithmKarney )
891+ assert .NoError (t , err )
892+ targetGeog , err := iceberg .GeographyTypeOf ("srid:4326" , iceberg .EdgeAlgorithmSpherical )
893+ assert .NoError (t , err )
894+
895+ geoSchema := iceberg .NewSchema (1 ,
896+ iceberg.NestedField {ID : 1 , Name : "id" , Type : iceberg .PrimitiveTypes .Int32 , Required : true },
897+ iceberg.NestedField {ID : 2 , Name : "geog" , Type : currentGeog , Required : false },
898+ )
899+ geoMeta , err := NewMetadata (geoSchema , nil , UnsortedSortOrder , "" , iceberg.Properties {
900+ PropertyFormatVersion : "3" ,
901+ })
902+ assert .NoError (t , err )
903+
904+ table := New ([]string {"geo" }, geoMeta , "" , nil , nil )
905+ txn := table .NewTransaction ()
906+
907+ _ , err = NewUpdateSchema (txn , true , false ).UpdateColumn ([]string {"geog" }, ColumnUpdate {
908+ FieldType : iceberg.Optional [iceberg.Type ]{Valid : true , Val : targetGeog },
909+ }).Apply ()
910+ assert .Error (t , err )
911+ assert .Contains (t , err .Error (), "cannot promote geography(srid:4269, karney) to geography(srid:4326, spherical)" )
912+ })
913+
864914 t .Run ("test add required field without default value" , func (t * testing.T ) {
865915 table := New ([]string {"id" }, testMetadata , "" , nil , nil )
866916 txn := table .NewTransaction ()
0 commit comments