Field calculator concatenation

5681
3
01-08-2014 11:22 AM
SteveShubert
New Contributor
Is there a way using the field calculator to concatenate the values from two  fields in a GeoEvent Definition into one of the existing fields?
0 Kudos
3 Replies
VladislavPlechnoy
New Contributor III
Field Calculator processor can be used to concatenate the values from as many different GeoEvent fields as you like. You just need to use a '+' operator that will work in 'concatenation mode' if one of the values is of type String. Depending on your field types you need to choose an expression format as follows:

1) [field of type String] + [field of any type] => This expression will concatenate 'String field value' with [field of any type].toString() value;

2) [field of any type] + '' + [field of any type] => This expression will concatenate [field of any type].toString() value with empty string value and then with [field of any type].toString() value. Notice a String constant here represented by two single quotes. This tells field calculator to auto-convert field values to strings and then concatenate them all together.

Assigning the result to either new field or one of the existing fields of the GeoEvent is a standard feature.

IN the upcoming release of GeoEvent 10.2.2 Field Calculator processor will be enhanced with support of 'String functions'. One of them will allow you to convert any field value into String explicitly. This will eliminate usage of string constant '' in the expression above.

Please let me know if you have more questions about Field Calculator capabilities.

Thanks,
Vlad.
0 Kudos
HeiJo
by
New Contributor II
Hi Vlad and everyone,
I have a string field named FlightName which I would like to update the value. I declare a new Processor as in this image:
[ATTACH=CONFIG]34761[/ATTACH]
But it doesn't work.

When I make the same with a numeric field, it works.
Please someone give any idea.
Thank you in advance

Jo

P/s: I already solve it! Just change double quote (" ") by single quote (' ') in Expression 🙂
VladislavPlechnoy
New Contributor III
Jo,

Your expression should look like this: FlightName + ' come into dangerous zone!'

Field Calculator fails because:
1) expression uses double quotes to denote string literal -> single quotes are required instead;
2) doesn't support 'dot notation' -> therefore '.toString()' is invalid for the processor expression parser

Field Calculator has a built in type conversion mechanism that knows how to handle field values of different type depending on the logic of supplied expression so no explicit type conversion like '.toString()' is necessary.

Hope this helps to run the processor successfully.

Thanks,
Vlad.