Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datacontract export --format avro - array issue #243

Closed
gpthome opened this issue Jun 5, 2024 · 3 comments
Closed

datacontract export --format avro - array issue #243

gpthome opened this issue Jun 5, 2024 · 3 comments

Comments

@gpthome
Copy link

gpthome commented Jun 5, 2024

I'm trying to generate AVRO output which includes ARRAYS. I tried a couple different versions of ...

  simple_array:
    type: array
    items: {'type': 'string'}
    default: []
    required: false

Instead of items: {'type': 'string'}, I tried items: string and received "DataContractException: Run operation failed: [lint] Check that data contract YAML is valid - None - failed - data.models.catalog.fields.simple_array.items must be object - datacontract". Not sure if I'm defining it correctly.

Current output no matter the 'required' value...

    {
      "name": "simple_array",
      "type": "array"
    },

Expected output with required: true...

        {
            "name": "simple_array",
            "type": {
                "type": "array",
                "items": "string",
                "default": []
            }
        },

Expected output with required: false...

        {
            "name": "simple_array",
            "type": [
                "null",
                {
                    "type": "array",
                    "items": "string"
                }
            ],
            "default": null
        },

I believe all data types are missing the "null" union in the export when required: false,.

@jochenchrist
Copy link
Contributor

jochenchrist commented Jun 5, 2024

Confirming, this is a bug.

jochenchrist added a commit that referenced this issue Jun 7, 2024
@jochenchrist
Copy link
Contributor

jochenchrist commented Jun 7, 2024

The correct way to model arrays is (as you already figured out):

      tags:
        type: array
        items:
          type: string

The expected output is:

    {
      "name": "tags",
      "type": {
        "type": "array",
        "items": "string"
      }
    },

which I fixed for next release v0.10.8.

The required: false feature for avro export is another topic that has not been addressed, yet. If you need this feature, feel free to open an issue or PR.

@gpthome
Copy link
Author

gpthome commented Jun 7, 2024

Perfect. Yes, I will create a separate issue for the 'required' request.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants