{
  "$id": "https://open-metadata.org/schema/type/entityLineage.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Entity Lineage",
  "description": "This schema defines the type used for lineage of an entity.",
  "type": "object",
  "javaType": "org.openmetadata.catalog.type.EntityLineage",
  "definitions": {
    "columnLineage": {
      "type" : "object",
      "properties": {
        "fromColumns" : {
          "description": "One or more source columns identified by fully qualified column name used by transformation function to create destination column.",
          "type" : "array",
          "items" : {
            "$ref" : "../type/basic.json#/definitions/fullyQualifiedEntityName"
          }
        },
        "toColumn" : {
          "description": "Destination column identified by fully qualified column name created by the transformation of source columns.",
          "$ref" : "../type/basic.json#/definitions/fullyQualifiedEntityName"
        },
        "function" : {
          "description": "Transformation function applied to source columns to create destination column. That is `function(fromColumns) -> toColumn`.",
          "$ref" : "../type/basic.json#/definitions/sqlFunction"
        }
      }
    },
    "lineageDetails" : {
      "description" : "Lineage details including sqlQuery + pipeline + columnLineage.",
      "type" : "object",
      "properties": {
        "sqlQuery" : {
          "description": "SQL used for transformation.",
          "$ref" : "../type/basic.json#/definitions/sqlQuery"
        },
        "columnsLineage" : {
          "description" : "Lineage information of how upstream columns were combined to get downstream column.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/columnLineage"
          }
        },
        "pipeline" : {
          "description": "Pipeline where the sqlQuery is periodically run.",
          "$ref" : "../type/entityReference.json"
        }
      },
      "required": ["sqlQuery", "columnsLineage"]
    },
    "edge": {
      "description": "Edge in the lineage graph from one entity to another by entity IDs.",
      "type": "object",
      "javaType": "org.openmetadata.catalog.type.Edge",
      "properties": {
        "fromEntity": {
          "description": "From entity that is upstream of lineage edge.",
          "$ref": "basic.json#/definitions/uuid"
        },
        "toEntity": {
          "description": "To entity that is downstream of lineage edge.",
          "$ref": "basic.json#/definitions/uuid"
        },
        "description": {
          "$ref": "basic.json#/definitions/markdown"
        },
        "lineageDetails": {
          "description": "Optional lineageDetails provided only for table to table lineage edge.",
          "$ref": "#/definitions/lineageDetails"
        }
      },
      "required": ["fromEntity", "toEntity"],
      "additionalProperties": false
    },
    "entitiesEdge": {
      "description": "Edge in the lineage graph from one entity to another using entity references.",
      "type": "object",
      "javaType": "org.openmetadata.catalog.type.EntitiesEdge",
      "properties": {
        "fromEntity": {
          "description": "From entity that is upstream of lineage edge.",
          "$ref": "entityReference.json"
        },
        "toEntity": {
          "description": "To entity that is downstream of lineage edge.",
          "$ref": "entityReference.json"
        },
        "description": {
          "$ref": "basic.json#/definitions/markdown"
        },
        "lineageDetails": {
          "description": "Optional lineageDetails provided only for table to table lineage edge.",
          "$ref": "#/definitions/lineageDetails"
        }
      },
      "required": ["fromEntity", "toEntity"],
      "additionalProperties": false
    }
  },
  "properties": {
    "entity": {
      "description": "Primary entity for which this lineage graph is created.",
      "$ref": "entityReference.json"
    },
    "nodes": {
      "descriptions": "All the entities that are the nodes in the lineage graph excluding the primary entity.",
      "type": "array",
      "items": {
        "$ref": "entityReference.json"
      },
      "default": null
    },
    "upstreamEdges": {
      "descriptions": "All the edges in the lineage graph that are upstream from the primary entity.",
      "type": "array",
      "items": {
        "$ref": "#/definitions/edge"
      },
      "default": null
    },
    "downstreamEdges": {
      "descriptions": "All the edges in the lineage graph that are downstream from the primary entity.",
      "type": "array",
      "items": {
        "$ref": "#/definitions/edge"
      },
      "default": null
    }
  },
  "required": ["entity"],
  "additionalProperties": false
}
