Kriskras99 commented on issue #476:
URL: https://github.com/apache/avro-rs/issues/476#issuecomment-3943150444

   A type can only be flattened in a record field right?
   This is a type definition:
   ```json
   {
       "namespace": "org.apache.avro.codegentest.testdata",
       "name": "FixedType",
       "type": "fixed",
       "size": 12,
       "logicalType": "decimal",
       "precision": 28,
       "scale": 15
   }
   ```
   If we would add that to a record the correct way:
   ```json
   {
     "namespace": "org.apache.avro.codegentest.testdata",
     "type": "record",
     "name": "NestedLogicalTypesUnionFixedDecimal",
     "doc" : "Test nested types with logical types in generated Java classes",
     "fields": [
       {
         "name": "unionOfFixedDecimal",
         "type": {
           "namespace": "org.apache.avro.codegentest.testdata",
           "name": "FixedType",
           "type": "fixed",
           "size": 12,
           "logicalType": "decimal",
           "precision": 28,
           "scale": 15
         }
       }]
   }
   ```
   And flattened would look like this:
   ```json
   {
     "namespace": "org.apache.avro.codegentest.testdata",
     "type": "record",
     "name": "NestedLogicalTypesUnionFixedDecimal",
     "doc" : "Test nested types with logical types in generated Java classes",
     "fields": [
       {
         "namespace": "org.apache.avro.codegentest.testdata",
         "name": "FixedType",
         "type": "fixed",
         "size": 12,
         "logicalType": "decimal",
         "precision": 28,
         "scale": 15
       }]
   }
   ```
   In the flattened case there are a few possible confusions:
   1. The name field is both used for the field name and the type name
   2. Custom attributes can be put both on the type and on the field
   3. `logicalType` is ignored in the Python (and probably Java) implementations
   
   In the test you linked, the type is a union which contains a fixed type. 
Which is correct.


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

Reply via email to