{
  "type": "record",
  "name": "SchemaMetadata",
  "namespace": "com.linkedin.pegasus2avro.schema",
  "doc": "SchemaMetadata to describe metadata related to store schema",
  "fields": [
    {
      "name": "schemaName",
      "type": "string",
      "doc": "Schema name e.g. PageViewEvent, identity.Profile, ams.account_management_tracking",
      "validate": {
        "strlen": {
          "max": 500,
          "min": 1
        }
      }
    },
    {
      "name": "platform",
      "type": "string",
      "doc": "Standardized platform urn where schema is defined. The data platform Urn (urn:li:platform:{platform_name})",
      "java": {
        "class": "com.linkedin.pegasus2avro.common.urn.DataPlatformUrn"
      }
    },
    {
      "name": "version",
      "type": "long",
      "doc": "Every change to SchemaMetadata in the resource results in a new version. Version is server assigned. This version is differ from platform native schema version."
    },
    {
      "name": "created",
      "type": {
        "type": "record",
        "name": "AuditStamp",
        "namespace": "com.linkedin.pegasus2avro.common",
        "doc": "Data captured on a resource/association/sub-resource level giving insight into when that resource/association/sub-resource moved into a particular lifecycle stage, and who acted to move it into that specific lifecycle stage.",
        "fields": [
          {
            "name": "time",
            "type": "long",
            "doc": "When did the resource/association/sub-resource move into the specific lifecycle stage represented by this AuditEvent."
          },
          {
            "name": "actor",
            "type": "string",
            "doc": "The entity (e.g. a member URN) which will be credited for moving the resource/association/sub-resource into the specific lifecycle stage. It is also the one used to authorize the change.",
            "java": {
              "class": "com.linkedin.pegasus2avro.common.urn.Urn"
            }
          },
          {
            "name": "impersonator",
            "type": [
              "null",
              "string"
            ],
            "doc": "The entity (e.g. a service URN) which performs the change on behalf of the Actor and must be authorized to act as the Actor.",
            "default": null,
            "java": {
              "class": "com.linkedin.pegasus2avro.common.urn.Urn"
            }
          }
        ]
      },
      "doc": "An AuditStamp corresponding to the creation of this resource/association/sub-resource. A value of 0 for time indicates missing data.",
      "default": {
        "actor": "urn:li:corpuser:unknown",
        "impersonator": null,
        "time": 0
      }
    },
    {
      "name": "lastModified",
      "type": "com.linkedin.pegasus2avro.common.AuditStamp",
      "doc": "An AuditStamp corresponding to the last modification of this resource/association/sub-resource. If no modification has happened since creation, lastModified should be the same as created. A value of 0 for time indicates missing data.",
      "default": {
        "actor": "urn:li:corpuser:unknown",
        "impersonator": null,
        "time": 0
      }
    },
    {
      "name": "deleted",
      "type": [
        "null",
        "com.linkedin.pegasus2avro.common.AuditStamp"
      ],
      "doc": "An AuditStamp corresponding to the deletion of this resource/association/sub-resource. Logically, deleted MUST have a later timestamp than creation. It may or may not have the same time as lastModified depending upon the resource/association/sub-resource semantics.",
      "default": null
    },
    {
      "name": "dataset",
      "type": [
        "null",
        "string"
      ],
      "doc": "Dataset this schema metadata is associated with.",
      "default": null,
      "java": {
        "class": "com.linkedin.pegasus2avro.common.urn.DatasetUrn"
      }
    },
    {
      "name": "cluster",
      "type": [
        "null",
        "string"
      ],
      "doc": "The cluster this schema metadata resides from",
      "default": null
    },
    {
      "name": "hash",
      "type": "string",
      "doc": "the SHA1 hash of the schema content"
    },
    {
      "name": "platformSchema",
      "type": [
        {
          "type": "record",
          "name": "EspressoSchema",
          "doc": "Schema text of an espresso table schema.",
          "fields": [
            {
              "name": "documentSchema",
              "type": "string",
              "doc": "The native espresso document schema."
            },
            {
              "name": "tableSchema",
              "type": "string",
              "doc": "The espresso table schema definition."
            }
          ]
        },
        {
          "type": "record",
          "name": "OracleDDL",
          "doc": "Schema holder for oracle data definition language that describes an oracle table.",
          "fields": [
            {
              "name": "tableSchema",
              "type": "string",
              "doc": "The native schema in the dataset's platform. This is a human readable (json blob) table schema."
            }
          ]
        },
        {
          "type": "record",
          "name": "MySqlDDL",
          "doc": "Schema holder for MySql data definition language that describes an MySql table.",
          "fields": [
            {
              "name": "tableSchema",
              "type": "string",
              "doc": "The native schema in the dataset's platform. This is a human readable (json blob) table schema."
            }
          ]
        },
        {
          "type": "record",
          "name": "PrestoDDL",
          "doc": "Schema holder for presto data definition language that describes a presto view.",
          "fields": [
            {
              "name": "rawSchema",
              "type": "string",
              "doc": "The raw schema in the dataset's platform. This includes the DDL and the columns extracted from DDL."
            }
          ]
        },
        {
          "type": "record",
          "name": "KafkaSchema",
          "doc": "Schema holder for kafka schema.",
          "fields": [
            {
              "name": "documentSchema",
              "type": "string",
              "doc": "The native kafka document schema. This is a human readable avro document schema."
            },
            {
              "name": "keySchema",
              "type": [
                "null",
                "string"
              ],
              "doc": "The native kafka key schema as retrieved from Schema Registry",
              "default": null
            }
          ]
        },
        {
          "type": "record",
          "name": "BinaryJsonSchema",
          "doc": "Schema text of binary JSON schema.",
          "fields": [
            {
              "name": "schema",
              "type": "string",
              "doc": "The native schema text for binary JSON file format."
            }
          ]
        },
        {
          "type": "record",
          "name": "OrcSchema",
          "doc": "Schema text of an ORC schema.",
          "fields": [
            {
              "name": "schema",
              "type": "string",
              "doc": "The native schema for ORC file format."
            }
          ]
        },
        {
          "type": "record",
          "name": "Schemaless",
          "doc": "The dataset has no specific schema associated with it",
          "fields": []
        },
        {
          "type": "record",
          "name": "KeyValueSchema",
          "doc": "Schema text of a key-value store schema.",
          "fields": [
            {
              "name": "keySchema",
              "type": "string",
              "doc": "The raw schema for the key in the key-value store."
            },
            {
              "name": "valueSchema",
              "type": "string",
              "doc": "The raw schema for the value in the key-value store."
            }
          ]
        },
        {
          "type": "record",
          "name": "OtherSchema",
          "doc": "Schema holder for undefined schema types.",
          "fields": [
            {
              "name": "rawSchema",
              "type": "string",
              "doc": "The native schema in the dataset's platform."
            }
          ]
        }
      ],
      "doc": "The native schema in the dataset's platform."
    },
    {
      "name": "fields",
      "type": {
        "type": "array",
        "items": {
          "type": "record",
          "name": "SchemaField",
          "doc": "SchemaField to describe metadata related to dataset schema.",
          "fields": [
            {
              "name": "fieldPath",
              "type": "string",
              "doc": "Flattened name of the field. Field is computed from jsonPath field.",
              "Searchable": {
                "fieldName": "fieldPaths",
                "fieldType": "TEXT"
              }
            },
            {
              "name": "jsonPath",
              "type": [
                "null",
                "string"
              ],
              "doc": "Flattened name of a field in JSON Path notation.",
              "default": null,
              "Deprecated": true
            },
            {
              "name": "nullable",
              "type": "boolean",
              "doc": "Indicates if this field is optional or nullable",
              "default": false
            },
            {
              "name": "description",
              "type": [
                "null",
                "string"
              ],
              "doc": "Description",
              "default": null,
              "Searchable": {
                "boostScore": 0.1,
                "fieldName": "fieldDescriptions",
                "fieldType": "TEXT"
              }
            },
            {
              "name": "type",
              "type": {
                "type": "record",
                "name": "SchemaFieldDataType",
                "doc": "Schema field data types",
                "fields": [
                  {
                    "name": "type",
                    "type": [
                      {
                        "type": "record",
                        "name": "BooleanType",
                        "doc": "Boolean field type.",
                        "fields": []
                      },
                      {
                        "type": "record",
                        "name": "FixedType",
                        "doc": "Fixed field type.",
                        "fields": []
                      },
                      {
                        "type": "record",
                        "name": "StringType",
                        "doc": "String field type.",
                        "fields": []
                      },
                      {
                        "type": "record",
                        "name": "BytesType",
                        "doc": "Bytes field type.",
                        "fields": []
                      },
                      {
                        "type": "record",
                        "name": "NumberType",
                        "doc": "Number data type: long, integer, short, etc..",
                        "fields": []
                      },
                      {
                        "type": "record",
                        "name": "DateType",
                        "doc": "Date field type.",
                        "fields": []
                      },
                      {
                        "type": "record",
                        "name": "TimeType",
                        "doc": "Time field type. This should also be used for datetimes.",
                        "fields": []
                      },
                      {
                        "type": "record",
                        "name": "EnumType",
                        "doc": "Enum field type.",
                        "fields": []
                      },
                      {
                        "type": "record",
                        "name": "NullType",
                        "doc": "Null field type.",
                        "fields": []
                      },
                      {
                        "type": "record",
                        "name": "MapType",
                        "doc": "Map field type.",
                        "fields": [
                          {
                            "name": "keyType",
                            "type": [
                              "null",
                              "string"
                            ],
                            "doc": "Key type in a map",
                            "default": null
                          },
                          {
                            "name": "valueType",
                            "type": [
                              "null",
                              "string"
                            ],
                            "doc": "Type of the value in a map",
                            "default": null
                          }
                        ]
                      },
                      {
                        "type": "record",
                        "name": "ArrayType",
                        "doc": "Array field type.",
                        "fields": [
                          {
                            "name": "nestedType",
                            "type": [
                              "null",
                              {
                                "type": "array",
                                "items": "string"
                              }
                            ],
                            "doc": "List of types this array holds.",
                            "default": null
                          }
                        ]
                      },
                      {
                        "type": "record",
                        "name": "UnionType",
                        "doc": "Union field type.",
                        "fields": [
                          {
                            "name": "nestedTypes",
                            "type": [
                              "null",
                              {
                                "type": "array",
                                "items": "string"
                              }
                            ],
                            "doc": "List of types in union type.",
                            "default": null
                          }
                        ]
                      },
                      {
                        "type": "record",
                        "name": "RecordType",
                        "doc": "Record field type.",
                        "fields": []
                      }
                    ],
                    "doc": "Data platform specific types"
                  }
                ]
              },
              "doc": "Platform independent field type of the field."
            },
            {
              "name": "nativeDataType",
              "type": "string",
              "doc": "The native type of the field in the dataset's platform as declared by platform schema."
            },
            {
              "name": "recursive",
              "type": "boolean",
              "doc": "There are use cases when a field in type B references type A. A field in A references field of type B. In such cases, we will mark the first field as recursive.",
              "default": false
            },
            {
              "name": "globalTags",
              "type": [
                "null",
                {
                  "type": "record",
                  "name": "GlobalTags",
                  "namespace": "com.linkedin.pegasus2avro.common",
                  "doc": "Tag aspect used for applying tags to an entity",
                  "fields": [
                    {
                      "name": "tags",
                      "type": {
                        "type": "array",
                        "items": {
                          "type": "record",
                          "name": "TagAssociation",
                          "doc": "Properties of an applied tag. For now, just an Urn. In the future we can extend this with other properties, e.g.\npropagation parameters.",
                          "fields": [
                            {
                              "name": "tag",
                              "type": "string",
                              "doc": "Urn of the applied tag",
                              "Searchable": {
                                "addToFilters": true,
                                "fieldName": "tags",
                                "fieldType": "URN",
                                "filterNameOverride": "Tag",
                                "hasValuesFieldName": "hasTags"
                              },
                              "java": {
                                "class": "com.linkedin.pegasus2avro.common.urn.TagUrn"
                              }
                            }
                          ]
                        }
                      },
                      "doc": "Tags associated with a given entity"
                    }
                  ],
                  "Aspect": {
                    "name": "globalTags"
                  }
                }
              ],
              "doc": "Tags associated with the field",
              "default": null,
              "Searchable": {
                "/tags/*/tag": {
                  "boostScore": 0.5,
                  "fieldName": "fieldTags",
                  "fieldType": "URN"
                }
              }
            },
            {
              "name": "glossaryTerms",
              "type": [
                "null",
                {
                  "type": "record",
                  "name": "GlossaryTerms",
                  "namespace": "com.linkedin.pegasus2avro.common",
                  "doc": "Related business terms information",
                  "fields": [
                    {
                      "name": "terms",
                      "type": {
                        "type": "array",
                        "items": {
                          "type": "record",
                          "name": "GlossaryTermAssociation",
                          "doc": "Properties of an applied glossary term.",
                          "fields": [
                            {
                              "name": "urn",
                              "type": "string",
                              "doc": "Urn of the applied glossary term",
                              "Searchable": {
                                "addToFilters": true,
                                "fieldName": "glossaryTerms",
                                "fieldType": "URN",
                                "filterNameOverride": "Glossary Term"
                              },
                              "java": {
                                "class": "com.linkedin.pegasus2avro.common.urn.GlossaryTermUrn"
                              }
                            }
                          ]
                        }
                      },
                      "doc": "The related business terms"
                    },
                    {
                      "name": "auditStamp",
                      "type": "AuditStamp",
                      "doc": "Audit stamp containing who reported the related business term"
                    }
                  ],
                  "Aspect": {
                    "name": "glossaryTerms"
                  }
                }
              ],
              "doc": "Glossary terms associated with the field",
              "default": null,
              "Searchable": {
                "/terms/*/urn": {
                  "boostScore": 0.5,
                  "fieldName": "fieldGlossaryTerms",
                  "fieldType": "URN"
                }
              }
            },
            {
              "name": "isPartOfKey",
              "type": "boolean",
              "doc": "For schema fields that are part of complex keys, set this field to true\nWe do this to easily distinguish between value and key fields",
              "default": false
            },
            {
              "name": "jsonProps",
              "type": [
                "null",
                "string"
              ],
              "doc": "For schema fields that have other properties that are not modeled explicitly,\nuse this field to serialize those properties into a JSON string",
              "default": null
            }
          ]
        }
      },
      "doc": "Client provided a list of fields from document schema."
    },
    {
      "name": "primaryKeys",
      "type": [
        "null",
        {
          "type": "array",
          "items": "string"
        }
      ],
      "doc": "Client provided list of fields that define primary keys to access record. Field order defines hierarchical espresso keys. Empty lists indicates absence of primary key access patter. Value is a SchemaField@fieldPath.",
      "default": null
    },
    {
      "name": "foreignKeysSpecs",
      "type": [
        "null",
        {
          "type": "map",
          "values": {
            "type": "record",
            "name": "ForeignKeySpec",
            "doc": "Description of a foreign key in a schema.",
            "fields": [
              {
                "name": "foreignKey",
                "type": [
                  {
                    "type": "record",
                    "name": "DatasetFieldForeignKey",
                    "doc": "For non-urn based foregin keys.",
                    "fields": [
                      {
                        "name": "parentDataset",
                        "type": "string",
                        "doc": "dataset that stores the resource.",
                        "java": {
                          "class": "com.linkedin.pegasus2avro.common.urn.DatasetUrn"
                        }
                      },
                      {
                        "name": "currentFieldPaths",
                        "type": {
                          "type": "array",
                          "items": "string"
                        },
                        "doc": "List of fields in hosting(current) SchemaMetadata that conform a foreign key. List can contain a single entry or multiple entries if several entries in hosting schema conform a foreign key in a single parent dataset."
                      },
                      {
                        "name": "parentField",
                        "type": "string",
                        "doc": "SchemaField@fieldPath that uniquely identify field in parent dataset that this field references."
                      }
                    ]
                  },
                  {
                    "type": "record",
                    "name": "UrnForeignKey",
                    "doc": "If SchemaMetadata fields make any external references and references are of type com.linkedin.pegasus2avro.common.Urn or any children, this models can be used to mark it.",
                    "fields": [
                      {
                        "name": "currentFieldPath",
                        "type": "string",
                        "doc": "Field in hosting(current) SchemaMetadata."
                      }
                    ]
                  }
                ],
                "doc": "Foreign key definition in metadata schema."
              }
            ]
          }
        }
      ],
      "doc": "Map captures all the references schema makes to external datasets. Map key is ForeignKeySpecName typeref.",
      "default": null,
      "deprecated": "Use foreignKeys instead."
    },
    {
      "name": "foreignKeys",
      "type": [
        "null",
        {
          "type": "array",
          "items": {
            "type": "record",
            "name": "ForeignKeyConstraint",
            "doc": "Description of a foreign key constraint in a schema.",
            "fields": [
              {
                "name": "name",
                "type": "string",
                "doc": "Name of the constraint, likely provided from the source"
              },
              {
                "name": "foreignFields",
                "type": {
                  "type": "array",
                  "items": "string"
                },
                "doc": "Fields the constraint maps to on the foreign dataset",
                "Relationship": {
                  "/*": {
                    "entityTypes": [
                      "schemaField"
                    ],
                    "name": "ForeignKeyTo"
                  }
                }
              },
              {
                "name": "sourceFields",
                "type": {
                  "type": "array",
                  "items": "string"
                },
                "doc": "Fields the constraint maps to on the source dataset"
              },
              {
                "name": "foreignDataset",
                "type": "string",
                "doc": "Reference to the foreign dataset for ease of lookup",
                "Relationship": {
                  "entityTypes": [
                    "dataset"
                  ],
                  "name": "ForeignKeyToDataset"
                },
                "java": {
                  "class": "com.linkedin.pegasus2avro.common.urn.Urn"
                }
              }
            ]
          }
        }
      ],
      "doc": "List of foreign key constraints for the schema",
      "default": null
    }
  ],
  "Aspect": {
    "name": "schemaMetadata"
  }
}