> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reelevant.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Validate a datagraph schema and analyse the relevance of its joins

> Validate a datagraph schema and analyse the relevance of its joins

Performs two steps:
1. Structural validation of the schema (duplicate tables, unknown relation targets, column constraints, …).
2. For each relation declared in the schema, queries Pinot to measure how well the join keys
overlap between the two datasources (distinct-value intersection score).
The relation analysis is only executed when the schema is structurally valid.



## OpenAPI

````yaml /api-reference/openapi/datasources-api.json post /datagraph/schemas/validate
openapi: 3.0.0
info:
  title: datasources-api
  version: 0.0.0
  description: |-
    # Errors
    | Error code | Message | HTTP status code | Payload |
    | :--- | :--- | :--- | :--- |
    | number | string | 409 |  |
servers:
  - url: https://api.reelevant.com/v2/datasources/
    description: production
security: []
paths:
  /datagraph/schemas/validate:
    post:
      tags:
        - Datagraph
      summary: Validate a datagraph schema and analyse the relevance of its joins
      description: >-
        Validate a datagraph schema and analyse the relevance of its joins


        Performs two steps:

        1. Structural validation of the schema (duplicate tables, unknown
        relation targets, column constraints, …).

        2. For each relation declared in the schema, queries Pinot to measure
        how well the join keys

        overlap between the two datasources (distinct-value intersection score).

        The relation analysis is only executed when the schema is structurally
        valid.
      operationId: validate-datagraph-schema
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ValidateSchemaBody'
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    properties:
                      status:
                        type: string
                        enum:
                          - success
                    required:
                      - status
                    additionalProperties: false
                  - $ref: >-
                      #/components/schemas/InternalResponse_ValidateSchemaResponse
      security:
        - password_auth: []
components:
  schemas:
    ValidateSchemaBody:
      type: object
      properties:
        schema:
          $ref: '#/components/schemas/AnyValue'
      required:
        - schema
      additionalProperties: false
    InternalResponse_ValidateSchemaResponse:
      type: object
      properties:
        program:
          type: string
        version:
          type: string
        datetime:
          type: string
        status:
          type: string
        code:
          type: number
        message:
          type: string
        data:
          $ref: '#/components/schemas/ValidateSchemaResponse'
      required:
        - program
        - version
        - datetime
        - status
        - message
        - data
      additionalProperties: false
    AnyValue:
      description: Can be any value
      nullable: true
    ValidateSchemaResponse:
      type: object
      properties:
        validation:
          oneOf:
            - $ref: '#/components/schemas/SafeParseFailure'
            - $ref: >-
                #/components/schemas/SafeParseSuccess_Array_Intersection_datasourceId_string_name_string_columns_Array_Intersection_name_string_type_Union_string_number_boolean_name_url_date_description_text_integer_datetime_decimal_address_1_address_2_address_3_address_4_array_string_city_company_id_country_datetime_iso_event_id_event_name_image_url_latitude_longitude_locale_price_product_id_product_lifetime_record_string_reference_id_reference_ids_transaction_id_transaction_metadata_transaction_source_user_age_user_agent_user_birthday_user_tmp_id_workflow_event_mode_workflow_id_workflow_onsite_user_workflow_purchase_user_workflow_user_workflow_version_id_zipcode_nullable_Union_false_true_default_Union_undefined_null_string_number_false_true_Date_description_Union_undefined_string_description_Union_undefined_string_virtualColumns_Union_undefined_Array_Intersection_name_string_type_Union_string_number_boolean_name_url_date_description_text_integer_datetime_decimal_address_1_address_2_address_3_address_4_array_string_city_company_id_country_datetime_iso_event_id_event_name_image_url_latitude_longitude_locale_price_product_id_product_lifetime_record_string_reference_id_reference_ids_transaction_id_transaction_metadata_transaction_source_user_age_user_agent_user_birthday_user_tmp_id_workflow_event_mode_workflow_id_workflow_onsite_user_workflow_purchase_user_workflow_user_workflow_version_id_zipcode_nullable_Union_false_true_query_string_description_Union_undefined_string_uniqueKeys_Union_undefined_Array_Intersection_type_UniqueKey_columns_Array_string_description_Union_undefined_string_indexes_Union_undefined_Array_Intersection_type_Index_columns_Array_string_description_Union_undefined_string_relations_Union_undefined_Array_Intersection_type_Relation_columns_Array_string_reference_datasourceId_string_table_string_columns_Array_string_description_Union_undefined_string
        relations:
          type: array
          items:
            $ref: '#/components/schemas/RelationAnalysisResult'
      required:
        - validation
        - relations
      additionalProperties: false
    SafeParseFailure:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - 'false'
        error:
          $ref: '#/components/schemas/DatagraphValidationError'
      required:
        - success
        - error
      additionalProperties: false
    ? SafeParseSuccess_Array_Intersection_datasourceId_string_name_string_columns_Array_Intersection_name_string_type_Union_string_number_boolean_name_url_date_description_text_integer_datetime_decimal_address_1_address_2_address_3_address_4_array_string_city_company_id_country_datetime_iso_event_id_event_name_image_url_latitude_longitude_locale_price_product_id_product_lifetime_record_string_reference_id_reference_ids_transaction_id_transaction_metadata_transaction_source_user_age_user_agent_user_birthday_user_tmp_id_workflow_event_mode_workflow_id_workflow_onsite_user_workflow_purchase_user_workflow_user_workflow_version_id_zipcode_nullable_Union_false_true_default_Union_undefined_null_string_number_false_true_Date_description_Union_undefined_string_description_Union_undefined_string_virtualColumns_Union_undefined_Array_Intersection_name_string_type_Union_string_number_boolean_name_url_date_description_text_integer_datetime_decimal_address_1_address_2_address_3_address_4_array_string_city_company_id_country_datetime_iso_event_id_event_name_image_url_latitude_longitude_locale_price_product_id_product_lifetime_record_string_reference_id_reference_ids_transaction_id_transaction_metadata_transaction_source_user_age_user_agent_user_birthday_user_tmp_id_workflow_event_mode_workflow_id_workflow_onsite_user_workflow_purchase_user_workflow_user_workflow_version_id_zipcode_nullable_Union_false_true_query_string_description_Union_undefined_string_uniqueKeys_Union_undefined_Array_Intersection_type_UniqueKey_columns_Array_string_description_Union_undefined_string_indexes_Union_undefined_Array_Intersection_type_Index_columns_Array_string_description_Union_undefined_string_relations_Union_undefined_Array_Intersection_type_Relation_columns_Array_string_reference_datasourceId_string_table_string_columns_Array_string_description_Union_undefined_string
    : type: object
      properties:
        success:
          type: boolean
          enum:
            - 'true'
        data:
          type: array
          items:
            allOf:
              - type: object
                properties:
                  datasourceId:
                    type: string
                  name:
                    type: string
                  columns:
                    type: array
                    items:
                      allOf:
                        - type: object
                          properties:
                            name:
                              type: string
                            type:
                              oneOf:
                                - type: string
                                  enum:
                                    - string
                                - type: string
                                  enum:
                                    - number
                                - type: string
                                  enum:
                                    - boolean
                                - type: string
                                  enum:
                                    - name
                                - type: string
                                  enum:
                                    - url
                                - type: string
                                  enum:
                                    - date
                                - type: string
                                  enum:
                                    - description
                                - type: string
                                  enum:
                                    - text
                                - type: string
                                  enum:
                                    - integer
                                - type: string
                                  enum:
                                    - datetime
                                - type: string
                                  enum:
                                    - decimal
                                - type: string
                                  enum:
                                    - address_1
                                - type: string
                                  enum:
                                    - address_2
                                - type: string
                                  enum:
                                    - address_3
                                - type: string
                                  enum:
                                    - address_4
                                - type: string
                                  enum:
                                    - array_string
                                - type: string
                                  enum:
                                    - city
                                - type: string
                                  enum:
                                    - company_id
                                - type: string
                                  enum:
                                    - country
                                - type: string
                                  enum:
                                    - datetime_iso
                                - type: string
                                  enum:
                                    - event_id
                                - type: string
                                  enum:
                                    - event_name
                                - type: string
                                  enum:
                                    - image_url
                                - type: string
                                  enum:
                                    - latitude
                                - type: string
                                  enum:
                                    - longitude
                                - type: string
                                  enum:
                                    - locale
                                - type: string
                                  enum:
                                    - price
                                - type: string
                                  enum:
                                    - product_id
                                - type: string
                                  enum:
                                    - product_lifetime
                                - type: string
                                  enum:
                                    - record_string
                                - type: string
                                  enum:
                                    - reference_id
                                - type: string
                                  enum:
                                    - reference_ids
                                - type: string
                                  enum:
                                    - transaction_id
                                - type: string
                                  enum:
                                    - transaction_metadata
                                - type: string
                                  enum:
                                    - transaction_source
                                - type: string
                                  enum:
                                    - user_age
                                - type: string
                                  enum:
                                    - user_agent
                                - type: string
                                  enum:
                                    - user_birthday
                                - type: string
                                  enum:
                                    - user_tmp_id
                                - type: string
                                  enum:
                                    - workflow_event_mode
                                - type: string
                                  enum:
                                    - workflow_id
                                - type: string
                                  enum:
                                    - workflow_onsite_user
                                - type: string
                                  enum:
                                    - workflow_purchase_user
                                - type: string
                                  enum:
                                    - workflow_user
                                - type: string
                                  enum:
                                    - workflow_version_id
                                - type: string
                                  enum:
                                    - zipcode
                            nullable:
                              type: boolean
                          required:
                            - name
                            - type
                            - nullable
                          additionalProperties: false
                        - type: object
                          properties:
                            default:
                              oneOf:
                                - type: string
                                - type: number
                                - type: boolean
                                  enum:
                                    - 'false'
                                - type: boolean
                                  enum:
                                    - 'true'
                                - type: string
                                  format: date-time
                              nullable: true
                            description:
                              type: string
                          additionalProperties: false
                required:
                  - datasourceId
                  - name
                  - columns
                additionalProperties: false
              - type: object
                properties:
                  description:
                    type: string
                  virtualColumns:
                    type: array
                    items:
                      allOf:
                        - type: object
                          properties:
                            name:
                              type: string
                            type:
                              oneOf:
                                - type: string
                                  enum:
                                    - string
                                - type: string
                                  enum:
                                    - number
                                - type: string
                                  enum:
                                    - boolean
                                - type: string
                                  enum:
                                    - name
                                - type: string
                                  enum:
                                    - url
                                - type: string
                                  enum:
                                    - date
                                - type: string
                                  enum:
                                    - description
                                - type: string
                                  enum:
                                    - text
                                - type: string
                                  enum:
                                    - integer
                                - type: string
                                  enum:
                                    - datetime
                                - type: string
                                  enum:
                                    - decimal
                                - type: string
                                  enum:
                                    - address_1
                                - type: string
                                  enum:
                                    - address_2
                                - type: string
                                  enum:
                                    - address_3
                                - type: string
                                  enum:
                                    - address_4
                                - type: string
                                  enum:
                                    - array_string
                                - type: string
                                  enum:
                                    - city
                                - type: string
                                  enum:
                                    - company_id
                                - type: string
                                  enum:
                                    - country
                                - type: string
                                  enum:
                                    - datetime_iso
                                - type: string
                                  enum:
                                    - event_id
                                - type: string
                                  enum:
                                    - event_name
                                - type: string
                                  enum:
                                    - image_url
                                - type: string
                                  enum:
                                    - latitude
                                - type: string
                                  enum:
                                    - longitude
                                - type: string
                                  enum:
                                    - locale
                                - type: string
                                  enum:
                                    - price
                                - type: string
                                  enum:
                                    - product_id
                                - type: string
                                  enum:
                                    - product_lifetime
                                - type: string
                                  enum:
                                    - record_string
                                - type: string
                                  enum:
                                    - reference_id
                                - type: string
                                  enum:
                                    - reference_ids
                                - type: string
                                  enum:
                                    - transaction_id
                                - type: string
                                  enum:
                                    - transaction_metadata
                                - type: string
                                  enum:
                                    - transaction_source
                                - type: string
                                  enum:
                                    - user_age
                                - type: string
                                  enum:
                                    - user_agent
                                - type: string
                                  enum:
                                    - user_birthday
                                - type: string
                                  enum:
                                    - user_tmp_id
                                - type: string
                                  enum:
                                    - workflow_event_mode
                                - type: string
                                  enum:
                                    - workflow_id
                                - type: string
                                  enum:
                                    - workflow_onsite_user
                                - type: string
                                  enum:
                                    - workflow_purchase_user
                                - type: string
                                  enum:
                                    - workflow_user
                                - type: string
                                  enum:
                                    - workflow_version_id
                                - type: string
                                  enum:
                                    - zipcode
                            nullable:
                              type: boolean
                            query:
                              type: string
                          required:
                            - name
                            - type
                            - nullable
                            - query
                          additionalProperties: false
                        - type: object
                          properties:
                            description:
                              type: string
                          additionalProperties: false
                  uniqueKeys:
                    type: array
                    items:
                      allOf:
                        - type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - UniqueKey
                            columns:
                              type: array
                              items:
                                type: string
                          required:
                            - type
                            - columns
                          additionalProperties: false
                        - type: object
                          properties:
                            description:
                              type: string
                          additionalProperties: false
                  indexes:
                    type: array
                    items:
                      allOf:
                        - type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - Index
                            columns:
                              type: array
                              items:
                                type: string
                          required:
                            - type
                            - columns
                          additionalProperties: false
                        - type: object
                          properties:
                            description:
                              type: string
                          additionalProperties: false
                  relations:
                    type: array
                    items:
                      allOf:
                        - type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - Relation
                            columns:
                              type: array
                              items:
                                type: string
                            reference:
                              type: object
                              properties:
                                datasourceId:
                                  type: string
                                table:
                                  type: string
                                columns:
                                  type: array
                                  items:
                                    type: string
                              required:
                                - datasourceId
                                - table
                                - columns
                              additionalProperties: false
                          required:
                            - type
                            - columns
                            - reference
                          additionalProperties: false
                        - type: object
                          properties:
                            description:
                              type: string
                          additionalProperties: false
                additionalProperties: false
      required:
        - success
        - data
      additionalProperties: false
    RelationAnalysisResult:
      type: object
      properties:
        fromDatasourceId:
          type: string
        fromTable:
          type: string
        fromColumn:
          type: string
        fromDistinctCount:
          type: number
          nullable: true
        toDatasourceId:
          type: string
        toTable:
          type: string
        toColumn:
          type: string
        toDistinctCount:
          type: number
          nullable: true
        matchCount:
          type: number
          nullable: true
        matchPercentage:
          type: number
          nullable: true
        error:
          type: string
      required:
        - fromDatasourceId
        - fromTable
        - fromColumn
        - fromDistinctCount
        - toDatasourceId
        - toTable
        - toColumn
        - toDistinctCount
        - matchCount
        - matchPercentage
      additionalProperties: false
    DatagraphValidationError:
      type: object
      properties:
        issues:
          type: array
          items:
            $ref: '#/components/schemas/ValidationIssue'
        name:
          type: string
        message:
          type: string
        stack:
          type: string
      required:
        - issues
        - name
        - message
      additionalProperties: false
    ValidationIssue:
      type: object
      properties:
        message:
          type: string
        path:
          type: array
          items:
            oneOf:
              - type: string
              - type: number
      required:
        - message
        - path
      additionalProperties: false
  securitySchemes:
    password_auth:
      type: oauth2
      flows:
        password:
          tokenUrl: https://api.reelevant.com/v1/auth/token
          refreshUrl: https://api.reelevant.com/v1/auth/token
          scopes: {}

````