Reputation: 421
I'm trying to replace an empty field with nulls in an UpdateRecord processor.
/title ${field.value:replaceEmpty(null)}
This fails because "null" is not a valid keyword. How does one specify null in the nifi expression language?
Upvotes: 3
Views: 5720
Reputation: 1
It is giving answer as { "fieldname" : "null" }
here null is a string not a null value.
Upvotes: 0
Reputation: 21
There is a trick using RecordPath
, if the field value is blank you can do this to get a null value.
/fieldName[not(isBlank(/fieldName))]
Upvotes: 1
Reputation: 14184
You can use the literal()
function to return a String value that is the exact input to the function, and you can nest that inside your replaceEmpty
method. Try using the expression ${field.value:replaceEmpty(${literal('null')})}
.
If you are doing this in the UpdateRecord
processor, you want to use Apache NiFi RecordPath syntax, not Expression Language. I believe the CSVReader
and others parse even a field value containing only spaces to empty, so a regular expression like replaceRegex( /title, '^(?![\s\S])$', 'null' )
doesn't work.
My suggestion would be to file a Jira requesting this capability. In the mean time, do not use UpdateRecord
for this, but rather ReplaceText
with a regular expression like ,\s?,
for an empty CSV value and replace it with null
.
Upvotes: 1