However, when it goes through the field mapper, i am seeing some strange behavior. The fields is only mapped once when it has the same value as another instance:
Any idea why this is?
Page 1 / 1
@bsayed that is a strange behaviour. Please can you share the sample data in JSON and I can give it a try.
I am attaching the pipeline , can you please import it and try and check if it helps.
@Bikram I did as you suggested:
Still the same issue:
I tried to import your pipeline:
Any other suggestions? is this a bug in version 3.22.0?
@bsayed
I am not sure if its bug or not in 3.22.0 and i am not sure if i can get the version 3.22.0 or not.
If its there i can try it.
Can you please create a dummy pipeline and send me the pipeline and let me try to import it and check how it behaves.
@Bikram Here is the dummy pipeline. when I preview it, I have the same issue as before:
@bsayed
Issue in the data collector version .
May i know why its very old version you are using :)
@Bikram This is just what my company uses, I don't handle the version. 😀 Looks like we need to upgrade however
I tried solving this with a java script evaluator:
var records = sdc.records; for (var i = 0; i < records.length; i++) { try { var auditDetailList = records[i].value.auditDetailList.value; updateKeysAndPaths(auditDetailList);
sdc.output.write(records[i]); } catch (e) { // Send record to error sdc.error.write(records[i], e); } }
function updateKeysAndPaths(obj) { var stack = [obj];
while (stack.length > 0) { var current = stack.pop();
if (Array.isArray(current)) { current.forEach(function (item) { if (typeof item === 'object') { stack.push(item); } }); } else if (typeof current === 'object') { for (var key in current) { if (current.hasOwnProperty(key)) { var value = current[key]; if (typeof value === 'object') { stack.push(value); }
I got it to work in my browser console, however, this doesn't seem to work in streamsets. Is there any other workaround that will solve this issue, other than upgrading versions?
@bsayed
For now you just go ahead to use the same field mapper twice and proceed further. I will provide you the concrete result tomorrow .
Let me check why its behaving like this , when i am taking your input data , i am also getting the same issue.
Need to do some analysis on it .
@bsayed
In Streamsets you can use java script processor and use your code which is working fine in your console.
Just give a try.
@Bikram
Thanks you for your help, its greatly appreciated.
So you have the issue on the imported pipeline I sent you? If so, then there must be a bug in 3.22.0 that is fixed somewhere along the way to 5.5.0
Also, using 2 field mappers in not a solution, because it only works twice in the same instance of key value pairs.
ex: if "auditedField": "axle count", "originalValue": "3", "auditedValue": "4"
is seen 3 times, then I would need 3 field mappers. if it is seen 4 times, then I would need 4 field mappers and so on.
Since I cannot guarantee how many instances of the above same key value pairs will exist in a message, adding 2 field mappers doesn't fully solve the issue.
@bsayed
We can handle it in a different way , i hope it will help you to fix the issue.
@Bikram what is your suggestion to handle it in a different way?
@bsayed
can you please give a try the attached pipeline and check if it helps
I did the necessary changes in your pipeline.
@Bikram
Adding the pivoter → mapper is working. Thank you for your help in solving this issue!😀😀😀 Greatly appreciate it.