Import and Export a Logical Data Model

For project administrators only

You can export a logical data model (LDM) from the LDM Modeler to a JSON file. You can also import an LDM from a JSON file into the LDM Modeler.

Here are some situations when you may want to export or import the LDM:

  • You need to recreate the same LDM in another workspace.
    Export the LDM from the source workspace and then import it from the JSON file into the target workspace. Alternatively, you can execute the API for publishing the LDM to a workspace (you can use the content of the model key from the JSON file in the request body).
  • You want to keep a version of the LDM that exists at a certain point or create a backup file.
    Export the LDM and store the JSON file in a versioning system or a dedicated location.
  • You want to save an unfinished LDM so that you can complete it later.
    Export the LDM and store the JSON file. When you are ready to resume your work, import the LDM back into the workspace from the JSON file and proceed with building the LDM.

Contents:

JSON File Example

The JSON file describes the LDM objects and their relations.

Imagine you have the following simple LDM:

When the LDM is exported, the following JSON file is generated:

{
  "metaVersion": "1",
  "project": "{project_id}",
  "time": "yyyy-mm-dd HH:DD:SS",
  "model": {
    "projectModel": {
      "datasets": [
        {
          "dataset": {
            "identifier": "dataset.products",
            "title": "Products",
            "anchor": {
              "attribute": {
                "identifier": "attr.products.productid",
                "title": "Product Id",
                "folder": "Products",
                "labels": [
                  {
                    "label": {
                      "identifier": "label.products.productid",
                      "title": "Product Id",
                      "type": "GDC.text",
                      "dataType": "VARCHAR(128)"
                    }
                  }
                ]
              }
            },
            "attributes": [
              {
                "attribute": {
                  "identifier": "attr.products.product_name",
                  "title": "Product Name",
                  "folder": "products",
                  "labels": [
                    {
                      "label": {
                        "identifier": "label.products.product_name",
                        "title": "Product Name",
                        "type": "GDC.text",
                        "dataType": "VARCHAR(255)"
                      }
                    }
                  ]
                }
              }
            ],
            "production": true
          }
        },
        {
          "dataset": {
            "identifier": "dataset.orderlines",
            "title": "Order Lines",
            "anchor": {
              "attribute": {
                "identifier": "attr.orderlines.factsof",
                "title": "Records of Order Lines",
                "description": "Records of Order Lines",
                "folder": "Order Lines",
                "grain": []
              }
            },
            "attributes": [
              {
                "attribute": {
                  "identifier": "attr.orderlines.order_id",
                  "title": "Order Id",
                  "folder": "orderlines",
                  "labels": [
                    {
                      "label": {
                        "identifier": "label.orderlines.order_id",
                        "title": "Order Id",
                        "type": "GDC.text",
                        "dataType": "VARCHAR(255)"
                      }
                    }
                  ]
                }
              }
            ],
            "facts": [
              {
                "fact": {
                  "identifier": "fact.orderlines.price",
                  "title": "Price",
                  "folder": "orderlines",
                  "dataType": "DECIMAL(15,3)"
                }
              },
              {
                "fact": {
                  "identifier": "fact.orderlines.quantity",
                  "title": "Quantity",
                  "folder": "orderlines",
                  "dataType": "DECIMAL(15,3)"
                }
              }
            ],
            "references": [
              "date",
              "dataset.products"
            ],
            "production": true
          }
        }
      ],
      "dateDimensions": [
        {
          "dateDimension": {
            "identifier": "date.dataset.dt",
            "identifierPrefix": "date",
            "name": "date",
            "title": "Date",
            "urn": "urn:custom_v2:date",
            "bridges": [],
            "production": true
          }
        }
      ]
    }
  },
  "modelMapping": {
    "datasetMappings": [
      {
        "datasetMapping": {
          "fields": [
            {
              "fieldMapping": {
                "field": {
                  "type": "label",
                  "identifier": "label.products.productid"
                },
                "sourceColumn": {
                  "name": "product_id",
                  "dataType": "text"
                }
              }
            },
            {
              "fieldMapping": {
                "field": {
                  "type": "label",
                  "identifier": "label.products.product_name"
                },
                "sourceColumn": {
                  "name": "product_name",
                  "dataType": "text"
                }
              }
            }
          ],
          "references": [],
          "identifier": "dataset.products",
          "source": {
            "csv": {
              "name": "products.csv",
              "headerRow": 0,
              "delimiter": ","
            }
          }
        }
      },
      {
        "datasetMapping": {
          "fields": [
            {
              "fieldMapping": {
                "field": {
                  "type": "label",
                  "identifier": "label.orderlines.order_id"
                },
                "sourceColumn": {
                  "name": "order_id",
                  "dataType": "text"
                }
              }
            },
            {
              "fieldMapping": {
                "field": {
                  "type": "fact",
                  "identifier": "fact.orderlines.price"
                },
                "sourceColumn": {
                  "name": "price",
                  "dataType": "number"
                }
              }
            },
            {
              "fieldMapping": {
                "field": {
                  "type": "fact",
                  "identifier": "fact.orderlines.quantity"
                },
                "sourceColumn": {
                  "name": "quantity",
                  "dataType": "number"
                }
              }
            }
          ],
          "references": [
            {
              "referenceMapping": {
                "target": {
                  "type": "date",
                  "identifier": "date"
                },
                "sourceColumn": {
                  "name": "date",
                  "dataType": "date",
                  "format": "yyyy-MM-dd"
                }
              }
            },
            {
              "referenceMapping": {
                "target": {
                  "type": "dataset",
                  "identifier": "dataset.products"
                },
                "sourceColumn": {
                  "name": "dataset_products",
                  "dataType": "text"
                }
              }
            }
          ],
          "identifier": "dataset.orderlines",
          "source": {
            "csv": {
              "name": "order_lines.csv",
              "headerRow": 0,
              "delimiter": ","
            }
          }
        }
      }
    ]
  },
  "layout": {
    "objects": [
      {
        "identifier": {
          "type": "dataset",
          "id": "dataset.products"
        },
        "collapse": false,
        "x": 100,
        "y": 654
      },
      {
        "identifier": {
          "type": "dataset",
          "id": "dataset.orderlines"
        },
        "collapse": false,
        "x": 361,
        "y": 527
      },
      {
        "identifier": {
          "type": "templateDataset",
          "id": "date"
        },
        "collapse": true,
        "x": 122.5,
        "y": 887
      }
    ]
  }
}

Export a Logical Data Model to a JSON File

You can export the LDM at any point of working in the LDM Modeler. The LDM does not have to be published to the workspace to be exported. Whatever exists in the LDM Modeler at the moment of exporting the LDM will be exported to a JSON file.

Steps:

  1. In the LDM Modeler (to learn how to access the LDM Modeler, click here), click the menu button on the top right, and click Export model to JSON.

    A JSON file with your LDM is generated.
  2. Follow the instructions in your browser to save the generated file.
    Your LDM is exported.

Import a Logical Data Model from a JSON File

When you are importing the LDM, the LDM from the imported JSON file replaces the LDM that you currently have open in the LDM Modeler (published or not published to the workspace). However, the changes are not applied until you publish the LDM to the workspace.

Steps:

  1. In the LDM Modeler (to learn how to access the LDM Modeler, click here), click the menu button on the top right, and click Import model from JSON.

    A warning message appears asking you to confirm the import.
  2. Click Proceed.
    You are prompted to browse for the JSON file.
  3. Select the JSON file to import.
    The import process starts. When the import completes, you see a message that the LDM has been imported.
  4. Close this message.
    The LDM is imported and is displayed in the LDM Modeler.
    At this point, the LDM is not published to your workspace yet. If you close the browser window or navigate from the tab, the imported LDM will not be saved.
  5. If you want to keep the imported LDM in the workspace, publish it to the workspace. To do so, click Publish.
    You are prompted to choose the mode of publishing. The Preserve data mode is selected by default.
  6. Select Overwrite, and click Publish.
    The publishing process starts. When the publishing completes, you see a message that the LDM has been published. Close this message.

After you have published the LDM, update the Output Stage to synchronize it with the updated LDM (see Create the Output Stage based on Your Logical Data Model).

Powered by Atlassian Confluence and Scroll Viewport.