Fokko commented on code in PR #8393:
URL: https://github.com/apache/iceberg/pull/8393#discussion_r1307236910
##########
python/tests/test_schema.py:
##########
@@ -724,6 +726,52 @@ def should_promote(file_type: IcebergType, read_type:
IcebergType) -> bool:
return False
+def test_identifier_fields_fails(table_schema_nested_with_struct_key_map:
Schema) -> None:
+ with pytest.raises(ValueError) as exc_info:
+ Schema(*table_schema_nested_with_struct_key_map.fields, schema_id=1,
identifier_field_ids=[999])
+ assert "Could not find field with id: 999" in str(exc_info.value)
+
+ with pytest.raises(ValueError) as exc_info:
+ Schema(*table_schema_nested_with_struct_key_map.fields, schema_id=1,
identifier_field_ids=[11])
+ assert "Identifier field 11 invalid: not a primitive type field" in
str(exc_info.value)
+
+ with pytest.raises(ValueError) as exc_info:
+ Schema(*table_schema_nested_with_struct_key_map.fields, schema_id=1,
identifier_field_ids=[3])
+ assert "Identifier field 3 invalid: not a required field" in
str(exc_info.value)
+
+ with pytest.raises(ValueError) as exc_info:
+ Schema(*table_schema_nested_with_struct_key_map.fields, schema_id=1,
identifier_field_ids=[28])
+ assert "Identifier field 28 invalid: must not be float or double field" in
str(exc_info.value)
+
+ with pytest.raises(ValueError) as exc_info:
+ Schema(*table_schema_nested_with_struct_key_map.fields, schema_id=1,
identifier_field_ids=[29])
+ assert "Identifier field 29 invalid: must not be float or double field" in
str(exc_info.value)
+
+ with pytest.raises(ValueError) as exc_info:
+ Schema(*table_schema_nested_with_struct_key_map.fields, schema_id=1,
identifier_field_ids=[23])
+ assert (
+ "Cannot add field zip as an identifier field: must not be nested in %s"
+ % table_schema_nested_with_struct_key_map.find_field("location")
+ in str(exc_info.value)
+ )
+
+ with pytest.raises(ValueError) as exc_info:
+ Schema(*table_schema_nested_with_struct_key_map.fields, schema_id=1,
identifier_field_ids=[26])
+ assert (
+ "Cannot add field x as an identifier field: must not be nested in %s"
Review Comment:
Nit: I prefer f-strings
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]