Ask Your Question

Is there a way to remove a field from a record based on an evaluator?

asked 2018-04-05 08:46:11 -0600

mstang gravatar image

updated 2018-04-05 10:52:39 -0600

metadaddy gravatar image

I'm having some issues with NULL handling in a downstream JSON DB and I'm trying to remove a field from a record if it's value is null. I know I could create a new field when the value is not null as a workaround but I couldn't figure out if I could delete a field in a JS evaluator for example.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-04-05 11:21:41 -0600

metadaddy gravatar image

Yes - you can delete a field in a JavaScript evaluator. The trick is to realize that record.value is actually a Java LinkedHashMap and not really a JavaScript map. For example:

record = records[i];

if (record.value['a'] == null) {

There is one wrinkle - if you try to do that as you're iterating through the fields in a record, you'll get a ConcurrentModificationException, so you have to save the keys you want to remove, then remove them after the loop, like this:

record = records[i];

var keysToRemove = [];
for (var key in record.value) {
  if (record.value[key] == null) {

for (var j in keysToRemove) {
edit flag offensive delete link more


Thanks! This is perfect, and it also answers a question I didn't ask which is "how do you iterate through the fields" :)

mstang gravatar imagemstang ( 2018-04-12 08:13:13 -0600 )edit

answered 2018-04-09 16:53:09 -0600

todd gravatar image

updated 2018-04-10 14:14:29 -0600

Another example outside of JS evaluator could be something similar to the following where a Stream Selector is configured to check for null condition and remove before writing to a destination.

In this example, stream 1 has been evaluated to true on the null check.

image description

edit flag offensive delete link more


Thanks, this would work if I was only concerned with one field, but I think it would be a bit harder to manage with many or an unknown group of fields.

mstang gravatar imagemstang ( 2018-04-12 08:12:02 -0600 )edit

Good point, I agree

todd gravatar imagetodd ( 2018-04-12 08:20:02 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-04-05 08:46:11 -0600

Seen: 1,163 times

Last updated: Apr 10 '18