Skip to content

Adding support for required fields #41

Open
@charlyraffellini

Description

Since JSON schema draft 4 object definition supports a required property. This property is an array of fields that should be present in the object instance.

Fields that are not required can be undefined. However, Spark schemas don't support undefined columns. At the moment not-nullable and no-required fields are marked as not-nullable in the generated Spark schema.

JSON Schema:

       {
         "type": "object",
         "required": [],
         "properties": {
           "size": {
             "type": "integer"
           }
         }
       }

The current Spark schema being generated (serialized as JSON):

{
  "type" : "struct",
  "fields" : [ {
    "name" : "size",
    "type" : "long",
    "nullable" : false,
    "metadata" : { }
  } ]
}

Proposed Spark schema (serialized as JSON):

{
  "type" : "struct",
  "fields" : [ {
    "name" : "size",
    "type" : "long",
    "nullable" : true,
    "metadata" : { }
  } ]
}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions