Update a DW Mapping Script

Updates an existing DW Mapping script.

Request Method Service URL

PUT

/api-metadata/v1/{access-key}/metadata/dwmappingscripts/{scriptId}

Request Headers

Content-Type=application/json

 

Request parameters

Required

Name

Type

Description

Possible values

type string The DW Mapping script type. Must be set to HIVE.
script string Script content in SQL.  
order string Priority in which script is executed.  

Optional

Name

Type

Description

Possible values

tenantId integer Your tenant ID.  
name string The name of the DW Mapping script to create.  
disableDefault boolean Whether pre-script overrides standard DW scripts. The default is false, which uses the standard DW Mapping script upsert logic. To instead use standard logic to delete, set to true.
  • false (default)
  • true
entityName string The name of the entity in the account.  
scriptId string The identifier of the script.  

Response parameters

Name

Type

Description

Possible values

tenantId integer Your tenant ID.  
name string Name of the DW Mapping script.  
versionTS date/time Timestamp when the DW Mapping script was last updated. Expressed in epoch time, down to milliseconds.  
active boolean Whether the DW Mapping script is active or not.
  • true
  • false
lastModifiedBy string Name of the user who last updated the DW Mapping script. Expressed in epoch time, down to milliseconds.  
createdBy string Name of the user who created the DW Mapping script.  
createdTS date/time Timestamp when the DW Mapping script was created. Expressed in epoch time, down to milliseconds.  
type string DW Mapping script type. HIVE
script string Script content in SQL.  
disableDefault boolean Whether pre-script overrides standard DW scripts. The default is false, which uses the standard DW Mapping script upsert logic. To instead use standard logic to delete, set to true.  
order integer Priority in which script is executed.  
entityName string Name of the entity in Oracle Unity.  
scriptId string The identifier of the script.  

Example

Update a DW Mapping script.

http://{AccountURL}/api-metadata/v1/e2a7a0df2410470d85ef69c8dad2bdb8/metadata/dwmappingscripts

Request body:

{
  "tenantId": 1,
  "name": "OrderItem",
  "type": "HIVE",
  "script": "INSERT INTO TABLE ${mcps:OrderItem:tableName|dw}\nPARTITION (`OrderEntryDate`)\nSELECT \n  ${MCPS:OrderItem:columns|default=subQuery.$columnName},\n  subQuery.`OrderEntryDate`\nFROM\n(\nSELECT \n  ${MCPS:OrderItem:columns|exclude=SourceCustomerID,OrderEntryTS:default=OI.$columnName},\n  O.`SourceCustomerID` as `SourceCustomerID`, \n  O.`OrderEntryTS` as `OrderEntryTS`, \n  from_unixtime(cast(O.`OrderEntryTS` as bigint),'YYYYMM') AS `OrderEntryDate`\nFROM  \n  ${mcps:OrderItem:tableName|raw} OI\nLEFT OUTER JOIN \n  (\n    SELECT\n      SourceOrderID, \n      SourceID,\n      udfs.max_value(SourceCustomerID, RowModifiedTS) AS SourceCustomerID,\n      udfs.max_value(OrderEntryTS, RowModifiedTS) AS OrderEntryTS\n    FROM \n        ${mcps:Order:tableName|raw} \n    GROUP BY \n      SourceOrderID, \n      SourceID\n  )O on OI.SourceOrderID = O.SourceOrderID\n        and OI.SourceID = O.SourceID\n)subQuery;",
  "disableDefault": false,
  "entityName": "OrderItem",
  "scriptId": "script1"
}

Response:

A successful response displays information about the DW Mapping script.

{
  "tenantId": 103,
  "name": "c_tTable_prescript",
  "versionTS": 1583430529986,
  "active": true,
  "lastModifiedBy": "MCPS_TEST_ADMIN_USER",
  "createdBy": "MCPS_TEST_ADMIN_USER",
  "createdTS": 1583429003728,
  "type": "HIVE",
  "script": "INSERT INTO TABLE ${mcps:c_tTable:tableName|dw}  SELECT ${MCPS:c_fan:columns|default=$columnName} FROM (SELECT concat('PrimaryID_',tTable_ID) AS ID,  tTable_ID as Sourcec_tTable_ID,  'PrimaryID' as SourceID, max(tenantid) as tenantid,  max(createdby) as createdby,  max(modifiedby) as modifiedby,  max(createdts) as createdts,  max(modifiedts) as modifiedts,  max(rowcreatedts) as rowcreatedts,  max(rowmodifiedts) as rowmodifiedts FROM ${mcps:tTable:tableName|raw}  WHERE tTable_ID_id IS NOT NULL  GROUP BY tTable_ID_ID) a;",
  "disableDefault": false,
  "order": 1,
  "entityName": "c_tTable",
  "scriptId": "c_tTable_prescript"
}

Learn more

DW Mapping API

Sitemap