Fokko commented on code in PR #6525: URL: https://github.com/apache/iceberg/pull/6525#discussion_r1069180082
########## python/tests/expressions/test_evaluator.py: ########## @@ -52,112 +55,126 @@ ) +def _record_simple(id: int, data: Optional[str]) -> Record: + r = Record(SIMPLE_SCHEMA.as_struct()) Review Comment: I removed it because we only constructed it in that way in the tests. I've re-added it slightly differently: ```python def test_record_positional_args() -> None: r = Record(1, "a", True) assert repr(r) == "Record[field1=1, field2='a', field3=True]" ``` This is what I ended up with: ```python def __init__(self, *data: Any, struct: Optional[StructType] = None) -> None: if struct is not None: self._position_to_field_name = {idx: field.name for idx, field in enumerate(struct.fields)} elif data is not None: self._position_to_field_name = {} for idx, d in enumerate(data): self._position_to_field_name[idx] = f"field{idx + 1}" self[idx] = d ``` This way we don't have the awkward if's where we have to check if it is positional or keyword based. WDYT? -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org