@@ -107,26 +107,26 @@ def test_schema(table_v2: Table) -> None:
107
107
NestedField (field_id = 1 , name = "x" , field_type = LongType (), required = True ),
108
108
NestedField (field_id = 2 , name = "y" , field_type = LongType (), required = True , doc = "comment" ),
109
109
NestedField (field_id = 3 , name = "z" , field_type = LongType (), required = True ),
110
- schema_id = 1 ,
111
110
identifier_field_ids = [1 , 2 ],
112
111
)
112
+ assert table_v2 .schema ().schema_id == 1
113
113
114
114
115
115
def test_schemas (table_v2 : Table ) -> None :
116
116
assert table_v2 .schemas () == {
117
117
0 : Schema (
118
118
NestedField (field_id = 1 , name = "x" , field_type = LongType (), required = True ),
119
- schema_id = 0 ,
120
119
identifier_field_ids = [],
121
120
),
122
121
1 : Schema (
123
122
NestedField (field_id = 1 , name = "x" , field_type = LongType (), required = True ),
124
123
NestedField (field_id = 2 , name = "y" , field_type = LongType (), required = True , doc = "comment" ),
125
124
NestedField (field_id = 3 , name = "z" , field_type = LongType (), required = True ),
126
- schema_id = 1 ,
127
125
identifier_field_ids = [1 , 2 ],
128
126
),
129
127
}
128
+ assert table_v2 .schemas ()[0 ].schema_id == 0
129
+ assert table_v2 .schemas ()[1 ].schema_id == 1
130
130
131
131
132
132
def test_spec (table_v2 : Table ) -> None :
@@ -266,31 +266,34 @@ def test_table_scan_ref_does_not_exists(table_v2: Table) -> None:
266
266
267
267
def test_table_scan_projection_full_schema (table_v2 : Table ) -> None :
268
268
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 (
270
271
NestedField (field_id = 1 , name = "x" , field_type = LongType (), required = True ),
271
272
NestedField (field_id = 2 , name = "y" , field_type = LongType (), required = True , doc = "comment" ),
272
273
NestedField (field_id = 3 , name = "z" , field_type = LongType (), required = True ),
273
- schema_id = 1 ,
274
274
identifier_field_ids = [1 , 2 ],
275
275
)
276
+ assert projection_schema .schema_id == 1
276
277
277
278
278
279
def test_table_scan_projection_single_column (table_v2 : Table ) -> None :
279
280
scan = table_v2 .scan ()
280
- assert scan .select ("y" ).projection () == Schema (
281
+ projection_schema = scan .select ("y" ).projection ()
282
+ assert projection_schema == Schema (
281
283
NestedField (field_id = 2 , name = "y" , field_type = LongType (), required = True , doc = "comment" ),
282
- schema_id = 1 ,
283
284
identifier_field_ids = [2 ],
284
285
)
286
+ assert projection_schema .schema_id == 1
285
287
286
288
287
289
def test_table_scan_projection_single_column_case_sensitive (table_v2 : Table ) -> None :
288
290
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 (
290
293
NestedField (field_id = 2 , name = "y" , field_type = LongType (), required = True , doc = "comment" ),
291
- schema_id = 1 ,
292
294
identifier_field_ids = [2 ],
293
295
)
296
+ assert projection_schema .schema_id == 1
294
297
295
298
296
299
def test_table_scan_projection_unknown_column (table_v2 : Table ) -> None :
@@ -983,20 +986,22 @@ def test_correct_schema() -> None:
983
986
)
984
987
985
988
# 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 (
987
991
NestedField (field_id = 1 , name = 'x' , field_type = LongType (), required = True ),
988
992
NestedField (field_id = 2 , name = 'y' , field_type = LongType (), required = True ),
989
993
NestedField (field_id = 3 , name = 'z' , field_type = LongType (), required = True ),
990
- schema_id = 1 ,
991
994
identifier_field_ids = [1 , 2 ],
992
995
)
996
+ assert projection_schema .schema_id == 1
993
997
994
998
# 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 (
996
1001
NestedField (field_id = 1 , name = 'x' , field_type = LongType (), required = True ),
997
- schema_id = 0 ,
998
1002
identifier_field_ids = [],
999
1003
)
1004
+ assert projection_schema .schema_id == 0
1000
1005
1001
1006
with pytest .warns (UserWarning , match = "Metadata does not contain schema with id: 10" ):
1002
1007
t .scan (snapshot_id = 234 ).projection ()
0 commit comments