ozenyunus35 commented on code in PR #4119:
URL: https://github.com/apache/iceberg-python/pull/4119#discussion_r4307074182


##########
pyiceberg/utils/schema_conversion.py:
##########
@@ -81,7 +81,15 @@
 AvroType = str | Any
 
 
+# Avro types that have a name and can be referred to by it later in the schema
+AVRO_NAMED_TYPES = {"record", "enum", "fixed"}

Review Comment:
   Done in 4f95b2e.
   



##########
pyiceberg/utils/schema_conversion.py:
##########
@@ -505,6 +522,18 @@ def __init__(self, schema_name: str | None) -> None:
             schema_name: The name of the root record.
         """
         self.schema_name = schema_name
+        self.defined_names: set[str] = set()
+
+    def _define_once(self, named_type: dict[str, Any]) -> AvroType:
+        """Return the definition of a named type the first time, and a 
reference to its name after that.
+
+        Avro allows only one definition per name; later uses must refer to it 
by name.
+        """
+        name = named_type["name"]
+        if name in self.defined_names:
+            return name
+        self.defined_names.add(name)
+        return named_type

Review Comment:
   Good idea, thanks. 4f95b2e drops the bookkeeping: a fixed, decimal or uuid 
type now gets the field-id of the field, list element or map key/value that 
uses it in its name (e.g. `decimal_10_2_1`), like records are named 
`r<field-id>`. Reading the reference form is unchanged.



-- 
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]

Reply via email to