I need to change a date from YEAR to a fixed YYYY-MM-DD
only if the value of the year is not null.
At the moment I have this
[
{
"operation": "modify-overwrite-beta",
"spec": {
"Passing?": "=concat(@(1,Passing),-01-01'"
}
}
]
Input:
{
"Passing": "2022",
"Comments": "NotMentioned",
"Team": "2",
"modified_date": "2023-01-27 13:41:39",
"Profile": "DM",
"JobRole": "Tester"
}
And the Output I’ll like is
{
"Passing": "2022-01-01",
"Comments": "NotMentioned",
"Team": "2",
"modified_date": "2023-01-27 13:41:39",
"Profile": "DM",
"JobRole": "Tester"
}
This is currently working fine but when I have a null value in Passing i get this, that I want to avoid.
{
"Passing": "null-01-01",
"Comments": "NotMentioned",
"Team": "2",
"modified_date": "2023-01-27 13:41:39",
"Profile": "DM",
"JobRole": "Tester"
}
I need to keep the "Passing" equal to "null" if there is no year in it.
2
Answers
I don’t know what your
Passing
value is if it’s notnull
, But you can use the below spec if you want to achieve to your desired output.Spec:
If
Passing
is null, you getnull
.If
Passing
is2023
, you get2023-01-01
The suffixing ? operator of
Passing
attribute checks out for the existence, not for nullability.You rather can use
isNull
function within a modify transformation spec in order to check the condition such aswhere
@(1,&)
replicates the current value of the attributePassing