rdblue commented on code in PR #40:
URL: https://github.com/apache/iceberg-python/pull/40#discussion_r1349764721
##########
pyiceberg/avro/resolver.py:
##########
@@ -233,7 +255,107 @@ def skip(self, decoder: BinaryDecoder) -> None:
pass
-class SchemaResolver(PrimitiveWithPartnerVisitor[IcebergType, Reader]):
+class WriteSchemaResolver(PrimitiveWithPartnerVisitor[IcebergType, Writer]):
+ def schema(self, schema: Schema, expected_schema: Optional[IcebergType],
result: Writer) -> Writer:
+ return result
+
+ def struct(self, struct: StructType, provided_struct:
Optional[IcebergType], field_writers: List[Writer]) -> Writer:
+ if not isinstance(provided_struct, StructType):
+ raise ResolveError(f"File/write schema are not aligned for struct,
got {provided_struct}")
+
+ provided_struct_positions: Dict[int, int] = {field.field_id: pos for
pos, field in enumerate(provided_struct.fields)}
Review Comment:
Is this backward? `provided_struct` is the file schema The `StructWriter`
uses `pos` to look up the data in the incoming struct, so it should be the
position in `struct`, the data's schema.
--
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]