Support Questions

Find answers, ask questions, and share your expertise

apache nifi- how to create a custom date format

New Contributor

I am new to nifi and I am trying to create a week_start_date and week_number from the date in json format.

I am using jolt transform.

The input is google ads api response.

This is the spec I use:

[{
"operation": "shift",
"spec": {

"customer_id": {
"*": "[&].customer_id"
},
"customer_name": {
"*": "[&].customer_name"
},
"account_currency_code": {
"*": "[&].account_currency_code"
},
"campaign_id": {
"*": "[&].campaign_id"
},

"campaign_name": {
"*": "[&].campaign_name"
},
"campaign_status": {
"*": "[&].campaign_status"
},

"ad_group_id": {
"*": "[&].ad_group_id"
},

"ad_group_name": {
"*": "[&].ad_group_name"
},

"clicks": {
"*": "[&].clicks"
},

"cost": {
"*": "[&].cost"
},

"impressions": {
"*": "[&].impressions"
},
"device": {
"*": "[&].device"
},
"date": {
"*": "[&].date"
},
"week_number": {
"*": "[&].week_number"
},
"year": {
"*": "[&].year"
},
"keywords": {
"*": "[&].keywords"
},
"keywords_id": {
"*": "[&].keywords_id"
}
}
},

{

"operation":"modify-default-beta",
"spec":{

"date": {
"date": "=intSubtract(@(1,date))"
}
}
}

]

The expected output should be:

[{
"customer_id": "2538943578",
"customer_name": "test.com",
"account_currency_code": "USD",
"campaign_id": "11137311251",
"campaign_name": "testers",
"campaign_status": "ENABLED",
"ad_group_id": "1111",
"ad_group_name": "tesst- E",
"clicks": "6",
"cost": "26580000",
"impressions": "40",
"device": "DESKTOP",
"date": "2021-12-01",
"week_number": "48",
"week_start_date":"2021-11-29"
"year": 2021,
"keywords": "test",
"keywords_id": "56357925842"
}]


the output I have:

[{
"customer_id": "2538943578",
"customer_name": "test.com",
"account_currency_code": "USD",
"campaign_id": "11137311251",
"campaign_name": "testers",
"campaign_status": "ENABLED",
"ad_group_id": "1111",
"ad_group_name": "tesst- E",
"clicks": "6",
"cost": "26580000",
"impressions": "40",
"device": "DESKTOP",
"date": "2021-12-01",
"week_number": "2021-11-29",
"year": 2021,
"keywords": "test",
"keywords_id": "56357925842"
}]

I am not sure on how to use correctly the modify-default-beta

Also I tried looking at the docs:
[https://github.com/bazaarvoice/jolt/tree/master/jolt-core/src/test/resources/json/shiftr][1]


[1]: https://github.com/bazaarvoice/jolt/tree/master/jolt-core/src/test/resources/json/shiftr


What is the correct way also to understand the structure?

0 REPLIES 0
Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.