Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-3898

[rust] compatibility fails with different namespaces

    XMLWordPrintableJSON

Details

    Description

      Current behavior

      SchemaCompatibility does not work properly when `namespace` is present.

      The following schemas are `FORWARD` compatible.

      use avro_rs::{Schema, schema_compatibility::SchemaCompatibility};
      
      let schema_1 = Schema::parse_str(r#"{
        "type": "record",
        "name": "Statistics",
        "fields": [
          { "name": "succes", "type": "int" },
          { "name": "fail", "type": "int" },
          { "name": "time", "type": "string" },
          { "name": "max", "type": "int", "default": 0 }
        ]
      }#").unwrap();
      
      let schema_2 = Schema::parse_str(r#"{
        "type": "record",
        "name": "Statistics",
        "fields": [
          { "name": "succes", "type": "int" },
          { "name": "fail", "type": "int" },
          { "name": "time", "type": "string" },
          { "name": "average", "type": "int"}
        ]
      }#").unwrap();
      

      When using `SchemaCompatibility::can_read(...)` the result is `true`:

      assert_eq!(true, SchemaCompatibility::can_read(&schema_1, &schema_2););
      

      However, when the `namespace` is added then the result is `false`

      let schema_3 = Schema::parse_str(r#"{
        "type": "record",
        "name": "Statistics",
        "namespace": "my.namespace"
        "fields": [
          { "name": "succes", "type": "int" },
          { "name": "fail", "type": "int" },
          { "name": "time", "type": "string" },
          { "name": "max", "type": "int", "default": 0 }
        ]
      }#").unwrap();
      
      assert_eq!(false, SchemaCompatibility::can_read(&schema_3, &schema_2););
      

      Desired behavior
      Namespace should not affect compatibility

      Notes

      • My team is going to provide a PR soon to fix it

      Attachments

        Issue Links

          Activity

            People

              mgrigorov Martin Tzvetanov Grigorov
              woile Santiago Fraire Willemoes
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h