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

C++ should support field default values

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.4
    • Fix Version/s: None
    • Component/s: c++
    • Labels:
      None
    • Tags:
      resolvingDecoder

      Description

      We found that resolvingDecoder could not provide bidirectional compatibility between different version of schemas.

      Especially for records, for example:

      First schema
      {
          "type": "record",
          "name": "TestRecord",
          "fields": [
              {
                  "name": "MyData",
      			"type": {
      				"type": "record",
      				"name": "SubData",
      				"fields": [
      					{
      						"name": "Version1",
      						"type": "string"
      					}
      				]
      			}
              },
      	{
                  "name": "OtherData",
                  "type": "string"
              }
          ]
      }
      
      Second schema
      {
          "type": "record",
          "name": "TestRecord",
          "fields": [
              {
                  "name": "MyData",
      			"type": {
      				"type": "record",
      				"name": "SubData",
      				"fields": [
      					{
      						"name": "Version1",
      						"type": "string"
      					},
      					{
      						"name": "Version2",
      						"type": "string"
      					}
      				]
      			}
              },
      	{
                  "name": "OtherData",
                  "type": "string"
              }
          ]
      }
      

      Say, node A knows only the first schema and node B knows the second schema, and the second schema has more fields.
      Any data generated by node B can be resolved by first schema 'cause the additional field is marked as skipped.
      But data generated by node A can not be resolved by second schema and throws an exception "Don't know how to handle excess fields for reader."
      This is because data is resolved exactly according to the auto-generated codec_traits which trying to read the excess field.
      The problem is we just can not only ignore the excess field in record, since the data after the troublesome record also needs to be resolved.
      Actually this problem stucked us for a very long time.

        Attachments

        1. AVRO-1335.patch
          12 kB
          Pierre de Freminville

          Activity

            People

            • Assignee:
              vimota Victor Mota
              Reporter:
              keyer Bin Guo
            • Votes:
              7 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: