cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Aggregate Snap - CONCAT function - input contains nulls / undefineds

ForbinCSD
Contributor

Judging from the options available in the Aggregate Snap, I would expect it to work much like the identically named aggregate functions in SQL. SQL functions like COUNT, AVG, SUM, and MAX conveniently skip over NULLs and return the same values as they would if the NULLs were not there.

However, for CONCAT this does not appear to be the case.

I am running into problems when the attribute I am trying to aggregate from the document stream either does not exist or is null.

For example, if I had $original.foo as the input field in the document stream that looked something like (โ€˜abcโ€™, โ€˜xyzโ€™, null, โ€˜aaโ€™, undefined, โ€˜bbโ€™) and was mapping CONCAT of that to an output field โ€œbarโ€, I would expect bar to look like: โ€œabc|xyz|aa|bbโ€. Instead I get errors: โ€˜foo was not found while evaluating the sub-expression โ€œ$original.fooโ€โ€™ and โ€˜$original.original.LegacyKey is undefined. Perhaps you meantโ€ฆโ€™

How do I write the input field expression so nulls and undefineds are simply ignored?

Or is this a bug in CONCAT / Aggregate?

Thanks in advance!

(PS: I donโ€™t think I want a string with back-to-back delimiters, e.g. โ€œabc|xyz||aa||bbโ€ if I can avoid it, but even that would be better than failing on error.)

1 ACCEPTED SOLUTION

skatpally
Former Employee

$.filter((value, key) => (key==โ€œfooโ€ && value!=โ€œnullโ€))

For reference.

Community1_2020_08_17.slp (7.2 KB)

View solution in original post

1 REPLY 1

skatpally
Former Employee

$.filter((value, key) => (key==โ€œfooโ€ && value!=โ€œnullโ€))

For reference.

Community1_2020_08_17.slp (7.2 KB)