# ----------------------------------------------------------------------------
#                         TABLE DESCRIPTION
# ----------------------------------------------------------------------------
name: result_liquids_supply
title: Liquid fuels supply
description: >
  Liquid fuels supply by year, technology, model and scenario. Results of scenario runs.
contract_type: ValueVariable

# ----------------------------------------------------------------------------
#                ----- Frictionless Table Schema -----
# ----------------------------------------------------------------------------
tableschema:
  # ----------------------------------------------------------------------------
  #                SEMANTIC FIELD DESCRIPTION
  # ----------------------------------------------------------------------------

  # ----------------------------------------------------------------------------
  #                        FOREIGN KEY CONSTRAINTS
  # ----------------------------------------------------------------------------
  # A list of field names that are jointly unique. As it is an assumption table,
  # it include the scenario information. E.g.
  primaryKey:
    [
      model,
      scenario_group,
      scenario_name,
      scenario_variant,
      country,
      year,
      unit,
      technology,
    ]

  foreignKeys:
    - fields: country
      reference:
        resource: dim_iso_region
        fields: id

    - fields: model
      reference:
        resource: dim_model
        fields: id

    - fields: [scenario_group, scenario_name, scenario_variant]
      reference:
        resource: dim_scenario
        fields: [group, name, variant]

    - fields: technology
      reference:
        resource: dim_tech_liquids
        fields: id

  # ----------------------------------------------------------------------------
  #                  FRICTIONLESS FIELDS/COLUMNS
  # ----------------------------------------------------------------------------
  fields:
    - name: model
      type: string
      title: Model
      description: Model that produced the data
      constraints:
        required: true

    - name: scenario_group
      type: string
      title: Scenario Group
      description: Scenario group
      constraints:
        required: true

    - name: scenario_name
      type: string
      title: Scenario Name
      description: Scenario name
      constraints:
        required: true

    - name: scenario_variant
      type: string
      title: Scenario Variant
      description: Scenario variant
      constraints:
        required: true

    - name: technology
      type: string
      title: Liquid Fuel Supply Technology
      description: Liquid fuel supply technology
      constraints:
        required: true

    - name: country
      type: string
      title: Country Code
      description: ISO 3166-1 alpha-2 country code
      constraints:
        required: true
        maxLength: 8

    - name: year
      type: integer
      title: Year
      description: Year to which the data value applies
      constraints:
        required: true

    - name: unit
      type: string
      title: Unit
      description: Measurement unit of the reported value
      constraints:
        required: true
        enum: ["TWh"]

    - name: value
      type: number
      title: Value
      description: Liquid fuels supply in the specified unit for the given country, year, technology, model, and scenario
      constraints:
        required: true
        minimum: 0
        maximum: 1000
