datacontract/datacontract-cli

datacontract export --format Avro - use 'required' attribute

Closed this issue · 1 comments

Request - use the "required" field in the model to generate AVRO output accordingly. I believe when set to false, use UNION with NULL being first.

If model is defined like this...

      tags:
        type: array
        items: 
          type: string
        default: []
        required: false
      removal_dt:
        type: timestamp
        required: false
      barcode:
        type: string
        required: false

Generate output similar to this...

        {
            "name": "tags",
            "type": [
                "null",
                {
                    "type": "array",
                    "items": "string"
                }
            ],
            "default": null
        },
        {
            "name": "removal_dt",
            "type": [
                "null",
                {
                    "type": "long",
                    "logicalType": "timestamp-millis"
                }
            ]
        },
        {
            "name": "barcode",
            "type": [
                "null",
                {
                    "type": "string",
                }
            ]
        },

Please include other data types like int as well. For the array, I'm not 100% sure if the generated AVRO output "default" should be null or "[ ]"

jsamson1's issue/PR above addresses the concerns of this issue. I'm closing this request. Thanks!