Tutorial Scenario Resolution - Part 4: Information Marts
In this part of the tutorial, we will focus on the creation of information marts. The main objective is to reproduce the following structure.

Steps:
Downlaod the file containing the queries:
Create New Queries in the appropriate source system
Create a State Machine to generate the im
Resolution
Open the file
dim_contracts:CODEDROP TABLE IF EXISTS im.dim_contracts; CREATE TABLE im.dim_contracts AS SELECT hc.bk AS contract_id, info.status AS contract_status, info.discount AS contract_discount, info.closing_date AS contract_closing_date, snapshot_dates.snapshot_date AS snapshot_date FROM dv.h_contract hc CROSS JOIN ref.snapshot_dates snapshot_dates INNER JOIN dv.sh_contract_ctx ctx ON ctx.hk = hc.hk INNER JOIN dv.vsh_contract_crm_info info ON info.hk = hc.hk WHERE ctx.src = 's01' AND ctx.load_dts <= snapshot_dates.snapshot_date AND ctx.load_end_dts > snapshot_dates.snapshot_date AND info.load_dts <= snapshot_dates.snapshot_date AND info.load_end_dts > snapshot_dates.snapshot_date;
fields name are important, depending on how you named each entities, you could face issue with the generation of the query.
Create IM in the appropriate sources:
CRM:
dim_cars
dim_contracts
dim_customers
fact_contract_details
HR
dim_employees
dim_shops
Create a state machine to generate the whole im
From States> State Machines, create a State Machine with the following query (language = JSON)
JSON{ "StartAt": "im-dim_cars", "TimeoutSeconds": 6000, "States": { "im-dim_cars": { "Type": "Task", "Resource": "ExecuteDataVaultQuery", "ResultPath": null, "Parameters": { "EnvironmentName": "main", "ProjectName": "Cars", "QueryType": "Reader", "QueryName": "SourceSystems/s01/dim_cars", "Type": "NonQuery", "CommandTimeout": 10 }, "Next": "im-dim_customers" }, "im-dim_customers": { "Type": "Task", "Resource": "ExecuteDataVaultQuery", "ResultPath": null, "TimeoutSeconds": 10, "Parameters": { "EnvironmentName": "main", "ProjectName": "Cars", "QueryType": "Reader", "QueryName": "SourceSystems/s01/dim_customers", "Type": "NonQuery", "CommandTimeout": 10 }, "Next": "im-dim_contracts" }, "im-dim_contracts": { "Type": "Task", "Resource": "ExecuteDataVaultQuery", "ResultPath": null, "TimeoutSeconds": 10, "Parameters": { "EnvironmentName": "main", "ProjectName": "Cars", "QueryType": "Reader", "QueryName": "SourceSystems/s01/dim_contracts", "Type": "NonQuery", "CommandTimeout": 10 }, "Next": "im-fact_contracts_details" }, "im-fact_contracts_details": { "Type": "Task", "Resource": "ExecuteDataVaultQuery", "ResultPath": null, "TimeoutSeconds": 10, "Parameters": { "EnvironmentName": "main", "ProjectName": "Cars", "QueryType": "Reader", "QueryName": "SourceSystems/s01/fact_contract_details", "Type": "NonQuery", "CommandTimeout": 10 }, "Next": "im-dim_shops" }, "im-dim_shops": { "Type": "Task", "Resource": "ExecuteDataVaultQuery", "ResultPath": null, "TimeoutSeconds": 10, "Parameters": { "EnvironmentName": "main", "ProjectName": "Cars", "QueryType": "Reader", "QueryName": "SourceSystems/s02/dim_shops", "Type": "NonQuery", "CommandTimeout": 10 }, "Next": "im-dim_employees" }, "im-dim_employees": { "Type": "Task", "Resource": "ExecuteDataVaultQuery", "ResultPath": null, "TimeoutSeconds": 10, "Parameters": { "EnvironmentName": "main", "ProjectName": "Cars", "QueryType": "Reader", "QueryName": "SourceSystems/s02/dim_employees", "Type": "NonQuery", "CommandTimeout": 10 }, "End": true } } }
Fields:
"StartAt": //im-”name of the table you want to generate first”
“Next”: //starts a new query execution
"TimeoutSeconds": //time before the execution is automatically stopped
"States": // define the steps the State Machine must execute
"im-dim_cars": { // name of the table
"Type": "Task",
"Resource": "ExecuteDataVaultQuery", // name of activity
"ResultPath": null,
"Parameters": {
"EnvironmentName": "main", // name of environment
"ProjectName": "Cars", // name of the project
"QueryType": "Reader",
"QueryName": "SourceSystems/s02/dim_employees", // path to the query, you will find this information by editing the im query, it will be the “new name” of the query (in Metavault)
"Type": "NonQuery",
"CommandTimeout": 10