@@ -107,26 +107,26 @@ def test_schema(table_v2: Table) -> None:
107107 NestedField (field_id = 1 , name = "x" , field_type = LongType (), required = True ),
108108 NestedField (field_id = 2 , name = "y" , field_type = LongType (), required = True , doc = "comment" ),
109109 NestedField (field_id = 3 , name = "z" , field_type = LongType (), required = True ),
110- schema_id = 1 ,
111110 identifier_field_ids = [1 , 2 ],
112111 )
112+ assert table_v2 .schema ().schema_id == 1
113113
114114
115115def test_schemas (table_v2 : Table ) -> None :
116116 assert table_v2 .schemas () == {
117117 0 : Schema (
118118 NestedField (field_id = 1 , name = "x" , field_type = LongType (), required = True ),
119- schema_id = 0 ,
120119 identifier_field_ids = [],
121120 ),
122121 1 : Schema (
123122 NestedField (field_id = 1 , name = "x" , field_type = LongType (), required = True ),
124123 NestedField (field_id = 2 , name = "y" , field_type = LongType (), required = True , doc = "comment" ),
125124 NestedField (field_id = 3 , name = "z" , field_type = LongType (), required = True ),
126- schema_id = 1 ,
127125 identifier_field_ids = [1 , 2 ],
128126 ),
129127 }
128+ assert table_v2 .schemas ()[0 ].schema_id == 0
129+ assert table_v2 .schemas ()[1 ].schema_id == 1
130130
131131
132132def test_spec (table_v2 : Table ) -> None :
@@ -266,31 +266,34 @@ def test_table_scan_ref_does_not_exists(table_v2: Table) -> None:
266266
267267def test_table_scan_projection_full_schema (table_v2 : Table ) -> None :
268268 scan = table_v2 .scan ()
269- assert scan .select ("x" , "y" , "z" ).projection () == Schema (
269+ projection_schema = scan .select ("x" , "y" , "z" ).projection ()
270+ assert projection_schema == Schema (
270271 NestedField (field_id = 1 , name = "x" , field_type = LongType (), required = True ),
271272 NestedField (field_id = 2 , name = "y" , field_type = LongType (), required = True , doc = "comment" ),
272273 NestedField (field_id = 3 , name = "z" , field_type = LongType (), required = True ),
273- schema_id = 1 ,
274274 identifier_field_ids = [1 , 2 ],
275275 )
276+ assert projection_schema .schema_id == 1
276277
277278
278279def test_table_scan_projection_single_column (table_v2 : Table ) -> None :
279280 scan = table_v2 .scan ()
280- assert scan .select ("y" ).projection () == Schema (
281+ projection_schema = scan .select ("y" ).projection ()
282+ assert projection_schema == Schema (
281283 NestedField (field_id = 2 , name = "y" , field_type = LongType (), required = True , doc = "comment" ),
282- schema_id = 1 ,
283284 identifier_field_ids = [2 ],
284285 )
286+ assert projection_schema .schema_id == 1
285287
286288
287289def test_table_scan_projection_single_column_case_sensitive (table_v2 : Table ) -> None :
288290 scan = table_v2 .scan ()
289- assert scan .with_case_sensitive (False ).select ("Y" ).projection () == Schema (
291+ projection_schema = scan .with_case_sensitive (False ).select ("Y" ).projection ()
292+ assert projection_schema == Schema (
290293 NestedField (field_id = 2 , name = "y" , field_type = LongType (), required = True , doc = "comment" ),
291- schema_id = 1 ,
292294 identifier_field_ids = [2 ],
293295 )
296+ assert projection_schema .schema_id == 1
294297
295298
296299def test_table_scan_projection_unknown_column (table_v2 : Table ) -> None :
@@ -983,20 +986,22 @@ def test_correct_schema() -> None:
983986 )
984987
985988 # Should use the current schema, instead the one from the snapshot
986- assert t .scan ().projection () == Schema (
989+ projection_schema = t .scan ().projection ()
990+ assert projection_schema == Schema (
987991 NestedField (field_id = 1 , name = 'x' , field_type = LongType (), required = True ),
988992 NestedField (field_id = 2 , name = 'y' , field_type = LongType (), required = True ),
989993 NestedField (field_id = 3 , name = 'z' , field_type = LongType (), required = True ),
990- schema_id = 1 ,
991994 identifier_field_ids = [1 , 2 ],
992995 )
996+ assert projection_schema .schema_id == 1
993997
994998 # When we explicitly filter on the commit, we want to have the schema that's linked to the snapshot
995- assert t .scan (snapshot_id = 123 ).projection () == Schema (
999+ projection_schema = t .scan (snapshot_id = 123 ).projection ()
1000+ assert projection_schema == Schema (
9961001 NestedField (field_id = 1 , name = 'x' , field_type = LongType (), required = True ),
997- schema_id = 0 ,
9981002 identifier_field_ids = [],
9991003 )
1004+ assert projection_schema .schema_id == 0
10001005
10011006 with pytest .warns (UserWarning , match = "Metadata does not contain schema with id: 10" ):
10021007 t .scan (snapshot_id = 234 ).projection ()
0 commit comments