Module data_request_api.stable.content.mapping_table

Mapping Table

The mapping_table dictionary defines how to map the three-base structure to the one-base structure. Each entry in the dictionary represents a table in the one-base structure and includes the information how to obtain it from the three-base structure.

Explanation of the dictionary keys:

Base ("source_base"): The base containing the table to be selected.

Table ("source_table"): The table to be selected from the "source_base".

Internal Mapping of record attributes ("internal_mapping"): Record attributes may point to records of other tables. However, there is no cross-linkage between the three bases, so these links need to be mapped as well. "internal_mapping" is a dictionary with the key corresponding to the record attributes to be mapped and the values containing the actual mapping information.

The mapping information is again a dictionary with the following keys:
- base_copy_of_table:
    If a copy of table corresponding to the record attribute exists in the current base,
    provide the name; otherwise, set to False.
- base:
    The base containing the original table the record attribute points to.
- table:
    The original table the record attribute points to.
- operation:
    The operation to perform on the attribute value (either "split" or "", if it is
    already provided as list or a string without comma separated values).
- map_by_key:
    A list of keys to map by.
- entry_type:
    The type of entry (either "record_id" or "name").

(Internal) Filters of record attributes ("internal_filters"): Not all records of the raw export shall be included since they may be labeled as junk or not be approved by the community. The filters are applied on all records and also internally on links to other records. "internal_filters" is a dictionary with the key corresponding to the record attributes used for filtering and the value another dictionary with the following possible keys: - operator: Can be one of "nonempty", "in", "not in" - values: A list of values, not necessary for "nonempty" operator.

Example Configuration

Suppose we want to map the "CMIP7 Variable Groups" key in the "Variables" table of the "Data Request Variables (Public)" base to a list of record IDs of "Variable Group" records in the "Data Request Opportunities (Public)" base.

We would define the mapping_table as follows: mapping_table = { "Variables": { "base": "Data Request Variables (Public)", "source_table": "Variables", "internal_mapping": { "CMIP7 Variable Groups": { "base_copy_of_table": False, "base": "Data Request Opportunities (Public)", "table": "Variable Group", "operation": "split", "map_by_key": ["Name"], "entry_type": "name", }, }, "internal_filters": { "Status": {"operator": "not in", "values": ["Junk"]}, } }, }