{
   "$schema":"https://json-schema.org/draft-04/schema#",
   "id":"https://api.dataplatform.ibm.com/schemas/common-pipeline/datarecord-metadata/datarecord-metadata-v1-schema.json#",
   "title":"Watson Data Platform Datarecord Metadata Schema",
   "description":"Metadata schema for datarecords in the Watson Data Platform",
   "definitions":{
      "record_schema":{
         "description":"Description of a datarecord including column types and metadata",
         "type":"object",
         "properties":{
           "id": {
             "description": "Unique identifier",
             "type": "string"
           },
           "name": {
             "description": "Name of datarecord",
             "type": "string"
           },
           "json_schema": {
             "description": "Refers to the JSON schema used to validate documents of this type",
             "enum": ["https://api.dataplatform.ibm.com/schemas/common-pipeline/datarecord-metadata/datarecord-metadata-v1-schema.json"],
             "type":"string"
           },
            "type":{
               "description":"Always 'struct' for datarecord schema",
               "type":"string"
            },
            "fields":{
               "description":"Array of field definitions",
               "type":"array",
               "minItems":0,
               "items":{
                  "$ref":"#/definitions/field"
               },
               "uniqueItems":true
            }
         },
         "required":[
            "fields"
         ]
      },
      "field":{
         "description":"Definition of a datarecord field",
         "type":"object",
         "properties":{
            "name":{
               "description":"Field name. Must be unique within the datarecord",
               "type":"string"
            },
            "type":{
               "description":"Field type. Can be a primitive type (string, integer, double, date, time, timestamp, binary, boolean, or other)",
               "type":"string"
            },
            "nullable":{
               "description":"Whether or not one can place null values into the field",
               "type":"boolean",
               "default":false
            },
            "metadata":{
               "$ref":"#/definitions/metadata"
            }
         },
         "required":[
            "name",
            "type"
         ]
      },
      "metadata":{
         "description":"Additional field metadata",
         "type":"object",
         "properties":{
            "description":{
               "description":"Field description",
               "type":"string"
            },
            "measure":{
               "description":"Field measurement level",
               "enum":[
                  "range",
                  "discrete",
                  "flag",
                  "set",
                  "ordered-set",
                  "typeless",
                  "collection",
                  "geospatial",
                  "default"
               ]
            },
            "modeling_role":{
               "description":"Field role for modeling",
               "enum":[
                  "input",
                  "target",
                  "both",
                  "none",
                  "partition",
                  "split",
                  "frequency",
                  "record-id"
               ]
            },
            "max_length":{
               "description":"Maximum length for fields. Length is unlimited when not present",
               "type":"number"
            },
            "decimal_precision":{
               "description":"Precision for decimal types",
               "type":"number"
            },
            "decimal_scale":{
               "description":"Scale for decimal types",
               "type":"number"
            },
            "values":{
               "description":"Array of unique categorical values for the column",
               "type":"array",
               "minItems":0,
               "items":{
                  "description":"A value discovered in the data",
                  "type":"string"
               },
               "uniqueItems":true
            },
            "range":{
               "description":"Minimum and maximum discovered values for scalar data",
               "type":"object",
               "properties":{
                  "min":{
                     "description":"Lowest value discovered in the data",
                     "type":"number"
                  },
                  "max":{
                     "description":"Highest value discovered in the data",
                     "type":"number"
                  }
               },
               "required":[
                  "min",
                  "max"
               ]
            }
         },
         "required":[

         ]
      }
   }
}
