Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Current »

Using core ontology for ETL processes is the best way to work with Data Rules, but sometimes it is necessary to extend the core resource to support additional fields and custom data. In this case, the best practice is to create an extension of the Data Rules core resource which will contain all the necessary information about the new fields.

An extension can be generated only of the CORE resource

This page contains guidance on how to work with extensions at Design and at Run time.

Supported Types of Extension Columns

Details below is required minimum to describe additional fields as an extension element:

  1. path - describes a path of the element;

  2. datatype - describes a type of the data ('string', ‘number', 'date’, etc.);

  3. formatdialect - an attribute of the datatype (as example "length": 16 for 'string').

All extension elements are stored in the “extension” complex element.

If the structure of the extension table is defined in advance, then extension element can have extra DB description:

  1. owner - database SCHEMA

  2. table_name - database TABLE

  3. column_name - database COLUMN

In this section

On this page

Fields for an Extension Table

When you create Data Rules extension which already has existing DB structure in market database, you have to mimic the same structure in Snowflake. Each element must be described to have the same table in Snowflake, as in below example:

"vocabulary":{
    "newField": {
		"path": "extension/newElement",
		"datatype": "integer",
		"owner": "CUSTOMDBO",
		"table_name": "POSITION_DETAIL_EXT",
		"column_name": "NEW_ELEMENT_INT",
		"formatdialect": {
			"precision": "38",
			"scale": "0"
		}
  },
  ...
}

When DB structure of extension is not predefined, you can create extension without DB parameters definition.

DB parameters for this case will be generated automatically:

  1. owner - {in_market_client_id}DBO

  2. table_name - {RESOURCE_NAME}_EXT

  3. column_name - {ELEMENT}

Information about the owner is taken from consul config dict by “in_market_client_id”.

https://consul.dev.az.eagleinvsys.com/ui/az-dev/kv/services/svc-eds/

Example:

"vocabulary":{
  "newElementChar": {
		"path": "extension/newElementChar",
		"datatype": "string",
		"formatdialect": {
			"length": 16
		}
  },
  ...
}

Fields for Summary Extension Tables

Fields for summary extension tables can be created if core resource has summary extension table (warehouseposition)

All these fields are provided in summary_vocabulary block.

Example when you have predefined DB structure:

"vocabulary":{
    "newField": {
		"path": "extension/positionDetailId",
		"datatype": "integer",
		"owner": "CLIENTID",
		"table_name": "POSITION_DETAIL_EXT",
		"column_name": "POSITION_DETAIL_ID",
		"formatdialect": {
			"precision": "38",
			"scale": "0"
		}
  },
  ...
},
"summary_vocabulary":{
    "newSummaryField": {
		"path": "extension/newSummaryField",
		"datatype": "integer",
		"owner": "JANUS",
		"table_name": "POSITION_EXT",
		"column_name": "POSITION_ID",
		"formatdialect": {
			"precision": "38",
			"scale": "0"
	},
	...
}

Example when you don`t have predefined DB structure:

"vocabulary":{
    "newField": {
		"path": "extension/positionDetailId",
		"datatype": "integer",
		"formatdialect": {
			"precision": "38",
			"scale": "0"
		}
  },
  ...
},
"summary_vocabulary":{
    "newSummaryField": {
		"path": "extension/newSummaryField",
		"datatype": "integer",
		"formatdialect": {
			"precision": "38",
			"scale": "0"
	},
	...
}

DB parameters for this case will be generated automatically:

  1. owner - {in_market_client_id}DBO

  2. table_name - {RESOURCE_NAME}_EXT

  3. table_name for summary vocabulary - {RESOURCE_NAME}_EXT_SUMMARY

  4. column_name - {ELEMENT}

Create an Extension

To generate an Extension via Rest API Endpoint in Vault:

Use the Ontology Publish Service API:

https://apps.dev.az.eagleinvsys.com/api/vault/ontology-publish/api/doc#/metadata-mapping-rest-api/submitEDSMetadataMappingPOST

image3.jpg

Where:

  • X-Eagle-Context - is Tenant ID;

  • Request body: see an example of the request below:

 RTR Generate Extension Using API Example
{
  "header": {
    "messageId": "663217F2147E56B7"
  },
  "parameters": {
    "data": "{ \"version\": 1.0, \"load\": { \"dataframe\": { \"_id\": \"warehouseposition\", \"type\": \"dftFile\", \"group_name\": \"Warehouse\", \"description\": \"warehouse position extension\", \"maxrows\": 999999, \"source_sink\": { \"sink_type\": \"ssFileType\", \"sink_params\": {}, \"source_descriptor_type\": \"SXml\", \"allow_format_discovery\": true, \"source_format_dialect\": { \"rootnodename\": \"EagleML\", \"rownodename\": \"warehouseposition\", \"txnheadernodename\": \"header\", \"txnnodename\": \"warehouseTransaction\", \"use_raw_parsing\": true } }, \"format\": \"xml\", \"vocabulary\": { \"positionId\": { \"path\": \"extension/positionId\", \"datatype\": \"integer\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_DETAIL_EXT\", \"column_name\": \"POSITION_ID\", \"formatdialect\": { \"precision\": \"38\", \"scale\": \"0\" } }, \"positionDetailId\": { \"path\": \"extension/positionDetailId\", \"datatype\": \"integer\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_DETAIL_EXT\", \"column_name\": \"POSITION_DETAIL_ID\", \"formatdialect\": { \"precision\": \"38\", \"scale\": \"0\" } }, \"testDate\": { \"path\": \"extension/testDate\", \"datatype\": \"date\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_DETAIL_EXT\", \"column_name\": \"TEST_DATE\", \"formatdialect\": { \"dialect\": \"YYYY-MM-DD\" } }, \"testInt\": { \"path\": \"extension/testInt\", \"datatype\": \"integer\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_DETAIL_EXT\", \"column_name\": \"TEST_INT\", \"formatdialect\": { \"precision\": \"38\", \"scale\": \"0\" } }, \"updateDate\": { \"path\": \"extension/updateDate\", \"datatype\": \"dateTime\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_DETAIL_EXT\", \"column_name\": \"UPDATE_DATE\", \"formatdialect\": { \"dialect\": \"YYYY-MM-DD HH24:MI:SS\" } }, \"updateSource\": { \"path\": \"extension/updateSource\", \"datatype\": \"string\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_DETAIL_EXT\", \"column_name\": \"UPDATE_SOURCE\", \"formatdialect\": { \"precision\": \"38\", \"scale\": \"0\" } }, \"testFloat\": { \"path\": \"extension/testFloat\", \"datatype\": \"number\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_DETAIL_EXT\", \"column_name\": \"TEST_FLOAT\", \"formatdialect\": { \"precision\": \"38\", \"scale\": \"12\" } }, \"testString\": { \"path\": \"extension/testString\", \"datatype\": \"string\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_DETAIL_EXT\", \"column_name\": \"TEST_STRING\", \"formatdialect\": { \"length\": \"50\" } } }, \"summary_vocabulary\": { \"positionId\": { \"path\": \"extension/positionId\", \"datatype\": \"integer\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_EXT\", \"column_name\": \"POSITION_ID\", \"formatdialect\": { \"precision\": \"38\", \"scale\": \"0\" } }, \"entityId\": { \"path\": \"extension/entityId\", \"datatype\": \"string\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_EXT\", \"column_name\": \"ENTITY_ID\", \"formatdialect\": { \"length\": \"8\" } }, \"effectiveDate\": { \"path\": \"extension/effectiveDate\", \"datatype\": \"date\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_EXT\", \"column_name\": \"EFFECTIVE_DATE\", \"formatdialect\": { \"dialect\": \"YYYY-MM-DD\" } }, \"srcIntfcInst\": { \"path\": \"extension/srcIntfcInst\", \"datatype\": \"integer\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_EXT\", \"column_name\": \"SRC_INTFC_INST\", \"formatdialect\": { \"precision\": \"38\", \"scale\": \"0\" } }, \"updateDate\": { \"path\": \"extension/updateDate\", \"datatype\": \"dateTime\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_EXT\", \"column_name\": \"UPDATE_DATE\", \"formatdialect\": { \"dialect\": \"YYYY-MM-DD HH24:MI:SS\" } }, \"updateSource\": { \"path\": \"extension/updateSource\", \"datatype\": \"string\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_EXT\",  \"column_name\": \"UPDATE_SOURCE\", \"formatdialect\": { \"length\": \"255\" } }, \"testDate1\": { \"path\": \"extension/testDate1\", \"datatype\": \"date\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_EXT\", \"column_name\": \"TEST_DATE1\", \"formatdialect\": { \"dialect\": \"YYYY-MM-DD\" } }, \"testInt1\": { \"path\": \"extension/testInt1\", \"datatype\": \"integer\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_EXT\", \"column_name\": \"TEST_INT1\", \"formatdialect\": { \"precision\": \"38\", \"scale\": \"0\" } }, \"testString1\": { \"path\": \"extension/testString1\", \"datatype\": \"string\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_EXT\", \"column_name\": \"TEST_STRING1\", \"formatdialect\": { \"length\": \"50\" }}, \"testFloat1\": { \"path\": \"extension/testFloat1\", \"datatype\": \"number\", \"owner\": \"TESTEXT\", \"table_name\": \"TESTEXT_POSITION_EXT\", \"column_name\": \"TEST_FLOAT1\", \"formatdialect\": { \"precision\": \"28\", \"scale\": \"12\" } } }, \"cache_policy\": { \"type\": \"aside\", \"cache_provider\": \"cache-manager-file\", \"storage_method\": \"keyvalue\", \"compression_codec\": \"\", \"encryption_codec\": \"N\", \"format_dialect\": \"mashup_csv_dialect\", \"ttl_delta\": 0, \"ttl_unique\": 60 } }, \"interface\": { \"_id\": \"warehouseposition\", \"group\": \"Warehouse\", \"format\": \"eaglemlformat\", \"dataset\": \"warehouseposition\", \"dataframe\": \"warehouseposition\", \"mashups\": {}, \"t_start_items_def\": [], \"t_group_start_items_def\": [], \"t_items_def\": [], \"dest_items\": {} } } }",
    "path": "/dynamic/metadata/custom/ontology/warehouseposition.json"
  },
  "generateldm": "N",
  "taskIdentifier": {
    "businessTaskId": "663217F2147E56B7#publish",
    "correlationId": "663217F2147E56B7"
  }
}

‘generateldm’ parameter should be passed as “N”

To Generate an Extension in Eagle via RTR

To generate an extension via RTR the following RTR should be used via stream eagle_ml-2-0_default_cm_exec_eds , the example is below.

Add extension fields to “load”: “dataframe”: “vocabulary” list in resource JSON definition. (see in expand)

 Part of the RTR with task parameters indicating a request for creating an extension:
<taskParameter>
	<name>ServiceName</name>
	<value>metadata</value>
</taskParameter>
<taskParameter>
	<name>ServiceMethodName</name>
	<value>refresh</value>
</taskParameter>
<taskParameter>
	<name>ResourceName</name>
	<value>warehouseposition</value>
</taskParameter>
<taskParameter>
	<name>useextension</name>
	<value>Y</value>
</taskParameter>
<taskParameter>
	<name>resourcejsondef</name>
	<value>
	{
		"version": "1.0",
		"load":{
			"dataframe":{
				"vocabulary":{
				    "newElementChar": {
						"path": "extension/newElementChar",
						"datatype": "string",
						"formatdialect": {
							"length": 16
						}
					},
					...
				}
			}
			...
		},
		"interface":{
			...
		}
	}
	</value>
</taskParameter>

Generated extension can be located in the below folder

dynamic/metadata/custom/ontology/{in_market_cliend_id}

Process Rule Generation for an Extension

  • A Processing rule is automatically generated when you create an extension.

  • Alter DDL for an extension will be automatically executed when you generate extension via API.

  • Cache will be stored in Redis and can be found via the following key:

eagle.ebs.resource:{in_market_cliend_id}_{resource_name}_{core_ontology version}

Example: eagle.ebs.resource_ik:CLI_WAREHOUSEPOSITION_1.0.1

The processing rule for the extension can be also generated via RTR for the corresponding core resource.

Alter DDL for an Extension

This is an optional step, the new tables and fields will be created in the DB during the execution of processing rule generation:

  1. The Extension describes tables/fields that do not exist in the database

  2. Additional Summary fields are required/added

Alter DDL RTR for extension resource is the same as Alter DDL RTR for a core resource.

Load and Extract Data to/from Extension Table

Congratulations! Now the extension is successfully generated and ready to use.

Load

To load data, please use the same RTR as for the Data Rules core resource.

New fields or Extensions elements are listed under the “extension” node:

Sample xml:

...
<extension>
  <newElementNum>1</newElementNum>
  <newElementString>str</newElementString>
</extension>
...

Sample csv:

...,extension/newElementNum,extension/newElementString,...
...,1,str,...

Extract

To extract data use the same RTR as for the core resource

Attention: if new DB fields are described in extension, then Alter DDL is mandatory step for Load and Extract. Otherwise, there will be failures.

How to Remove an Extension

  1. Delete extension ontology files from azure: https://portal.azure.com/#@eagleinvsys.net/resource/subscriptions/030c4927-46ed-4031-934e-d8cb445e75d0/resourceGroups/dev-eastus2-storage-eds/providers/Microsoft.Storage/storageAccounts/deveastus2eds/containersList


metadata/custom/ontology/{in_market_client_id}/{in_market-client_id}_{resource}*.json

Example for EDS tenant warehouseposition extension:
metadata/custom/ontology/da1t1cedstest/da1t1cedstest_warehouseposition.json
metadata/custom/ontology/da1t1cedstest/da1t1cedstest_warehouseposition-models.json

  1. Delete processing rule for extension from cache

https://apps.dev.az.eagleinvsys.com:8443/api/vault/metadata/api/doc#/processing-rule/deleteResource

resource-name = {in_market-client_id}_{resource}

resourceversion = current CORE ontology version (taken from Consul) + ontology versions from blob

Example for EDS tenant rule for warehouseposition extension:

name = DA1T1CEDSTEST_WAREHOUSEPOSITION
version = 2.0.39.1.0.1

  • No labels