HuwCampbell opened a new pull request, #3046:
URL: https://github.com/apache/avro/pull/3046

   ## What is the purpose of the change
   
   Default values have no special purpose for maps and arrays, and are only
   valid for record fields and enums.
   
   Having it in the examples is confusing, as people might have expectations
   around it behaving in a certain way.
   
   In the Java and Rust implementation, a default value listed here
   will be packed into the custom props and attributes payloads, and
   do not need to be of the same type; i.e., `default: "no default"` would
   be valid.
   
   Other implementations just ignore it and won't round trip it, for example:
   ```js
   MapType.prototype.toJSON = function () {
     return {type: 'map', values: this._values};
   };
   ```
   
   ## Verifying this change
   
   I wrote a small test in rust to validate my understanding; unfortunately
   using an assertion on Map would be confusing as the instance
   for `Eq` for `MapSchema` ignores the `attributes` field.
   
   ```rust
   #[test]
   fn avro_test_map_default() -> TestResult {
       // string uuid, represents as native logical type.
       let schema = json!(
       {
           "type": "map",
           "values": "long",
           "default": "4"
       });
       let parse_result = Schema::parse(&schema)?;
       assert_eq!(parse_result, Schema::Uuid);
   
       Ok(())
   }
   ```
   
   Resulting in:
   ```
   assertion `left == right` failed
     left: Map(MapSchema { types: Long, attributes: {"default": String("4")} })
   ```
   
   For Java I just read the code.
   


-- 
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: dev-unsubscr...@avro.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to