passing pipeline parameter in column mapping - azure

i am trying to configure a default value as my sourceID column.
my source is a FILe and my sink is a db table.
hence, i cant define the sourceID in sql query.
i created a parameter and defined the value.
intent to pass the parameter in the column mapping's dynamic content string.
however, i couldnt get the parameter value loaded into my table.
please advice if i made mistake in the dynamic content definition or there is better way to achieve the desired outcome.
{
"type":"TabularTranslator",
"columnMappings":{
"AS_OF_DATE":"AS_OF_DATE",
"SECTOR_ID":"SECTOR_ID",
"ASSET_GROUP":"ASSET_GROUP",
"REGION":"REGION",
"COUNTRY":"COUNTRY",
"FIELD":"FIELD",
"SECTOR_FLAG":"SECTOR_FLAG",
"PRODUCT":"PRODUCT",
"PERIODICITY":"PERIODICITY",
"UNIT_CODE":"UNIT_CODE",
"OPERATORSHIP":"OPERATORSHIP",
"OPRNAME":"OPRNAME",
"ACTUAL":"ACTUAL",
"PLAN":"PLAN",
"SOURCE_ID":"#{pipeline().parameters.sourceIDmpm}"
}
}

To dynamically map column in copy activity, please define a parameter with type 'Object' in pipeline:
"parameters": {
"columnMapping": {
"type": "Object"
}
}
and reference this parameter in copy activity like:
"translator": {
"value": "#pipeline().parameters.columnMapping",
"type": "Expression"
}
Please notice that you need to pass a JSON value to parameter. For example, I pass to the parameter
'columnMapping'.
{
"type": "TabularTranslator",
"columnMappings": {
"Prop_0": "Prop_0",
"Prop_1": "Prop_1", "Prop_2": "Prop_2"
}
}
For more details, you may refer the MSDN thread which addressing similar issue.
Hope this helps.

Related

how to store web activity result in a variable?

i have a web activity through which i am executing a rest API(execute queries)
this is a sample output of that:
{
"results": [
{
"tables": [
{
"rows": [
{
"[Value]": "2022-10-25T00:00:00Z"
}
]
}
]
}
]
i want to store the date value inside [Value] in a variable in adf
(variable value should be:2022-10-25T00:00:00Z)
but i am not able to do that because of square brackets
this is what i have tried
"#activity('SQl validation').output.results[0].tables[0].rows[0].[value]"
but it give me error
Position 73 Unrecognized expression: value
please suggest how i can fix this
Look at the following demonstration. I have the lookup which returns the following values.
To access the [companyId] attribute from this output array, I have used the following dynamic content (Using for loop just for demonstration):
#string(activity('myLookUp').output.value[item()]['[companyId]'])
So, you can use the following dynamic content instead:
#activity('SQl validation').output.results[0].tables[0].rows[0]['[value]']

How to get the key from a nested map (JSON) using given value in Groovy in JIRA Scriptrunner

Hope this question finds you all in good health.
As per title, would like to know how this is done in Groovy. Found a few, such as this, but the question and answer did not help.
The JSON is like this
def ​json = '''{
"boston": [
{
"name":"bob",
"phone":"242 123123",
},
{
"name":"alice",
"phone":"212-123-345",
}
],
"chicago": [
{
"name":"charlie",
"phone":"313-232-545",
},
{
"name":"denise",
"phone":"414-123-546",
}
]
}'''
But how do I use the value, for example bob to get boston?
When you use parsedjson['chicago']['email'], the result would be
[charlie#chicago.com, denise#chicago.com]
I tried to do something like
def getKey = parsedjson['email']?.key
as suggested here but in JIRA ScriptRunner console returned null
Any pointer is greatly appreciated in advance!
parsedjson['email']?.key returned null because key is not a List method. key is an Entry method so to find the key from a value you have to iterate through the Map's Entry Set.
Here's an example to get the city from the person's name using Map.find which returns an Entry:
parsedjson.find { it.value.find { it["name"] == "bob" } }.key

With a complex variable, how can I reference from one property to another?

Hi have the following complex variable in the template:
"rabbitVm": {
"size": "Standard_A2_v2",
"nicName": "[concat(variables('resourcePrefix'),'nicrabbit',parameters('tenantId'))]",
"machineName": "[concat('vmrabbit',parameters('tenantId'))]"
},
I want to add another property called "resourceName" which should be the machineName property with a prefix. I tried adding another property to the rabbitVM object, like this:
"resourceName": "[concat(variables('resourcePrefix'), variables('rabbitVm').machineName)]"
But I get an error that I can't reference the variable from within the variable.
What is the proper way to reference an another property in the same variable?

Elasticsearch-groovy index template

Is there any way to define an index template with the API of elasticsearch-groovy or elasticsearch-java? I want to apply "settings" (custom analyzers) and "mappings" (apply analyzer on fields) on it. The documentation only refers to index templatex but does not show a vaild example, how to apply them in a groovy closure. The example shown in the docs, adds the "settings" in the data (source) field.
edit: #Val Thank you for your reply, but if I use the source field as follows:
def templateR = client.admin.indices.putTemplate {
name "template_name"
source {
template "template_*"
}
}.actionGet()
... this results in a compiler-error: MissingMethodException No signature of method: ...source(). The following code:
def templateR = client.admin.indices.putTemplate {
name "lemato_template"
template "lemato_*"
settings {
number_of_shards= 1
}
}.actionGet()
gives me the compiler error No such property: number_of_shards. I'm not sure if I use the closure delegation correctly. Is something like .asMap() missing?
elasticsearch-groovy definitely provides support for creating/deleting index templates. The source closure may contain anything you can define for index templates. Something like this should work.
PutIndexTemplateResponse response = client.admin.indices.putTemplate {
name "my_template"
source {
template "index_*"
settings {
index {
number_of_shards = 5
number_of_replicas = 1
}
}
mappings {
// your mapping definitions
}
aliases {
// your aliases
}
}
}.actionGet()

Ext.XTemplate loop through object

my controller returns data like this:
{
"success":true,
"data":{
"35":{
"msg":{
"32":{
"module_id":"35",
"alert_id":"32",
"alert_datetime":"2012-11-28 16:19:19",
"param1_type":"imo",
"param1_value":"453465",
"param2_type":"",
"param2_value":"0",
"param3_type":"",
"param3_value":"0",
"msg":"triiiis dve",
"count":1
},
"33":{
"module_id":"35",
"alert_id":"33",
"alert_datetime":"2012-10-28 00:00:00",
"param1_type":"imo",
"param1_value":"54984",
"param2_type":"",
"param2_value":"0",
"param3_type":"",
"param3_value":"0",
"msg":"triis tri",
"count":1
}
}
},
"42":{
"msg":{
"1":{
"module_id":"42",
"alert_id":"1",
"alert_datetime":"2012-10-28 16:19:19",
"param1_type":"imo",
"param1_value":"9281906",
"param2_type":"",
"param2_value":"0",
"param3_type":"",
"param3_value":"0",
"msg":"",
"count":1
}
}
},
"39":{
"msg":{
"2":{
"module_id":"39",
"alert_id":"2",
"alert_datetime":"2012-10-28 12:36:31",
"param1_type":"imo",
"param1_value":"65464546",
"param2_type":"",
"param2_value":"0",
"param3_type":"",
"param3_value":"0",
"msg":"",
"count":1
}
}
}
}
}
After that I do this
that.tpl.overwrite(that.el, Ext.decode(response).data);
The problem is that I can't loop through the result object keys... I know how to loop through objects with pre-defined key names, but mine are dynamicaly generated...
Will appreciate some help, thanks!
I am assuming you have an idea of the depth of nesting (4 levels below the "data" element in this case):
You could loop through the data with Ext.Object.each (maybe there are some query methods for this too, not sure), looping through each element's children too. In case you use Ext.data.Model instances, you can use the Ext.data.association links to loop through the data.
In that case you could make a different template for each level and insert the result of each template in the template of the level above.
It sounds more difficult than it actually is I think.
foreach in templates is currently indeed only available for support subscribers.

Resources