Converting boolean value into string for concatenating with other string values

I have a vertex with 20 different columns and each column has a varying data type from INT, STRING, and BOOL. I am using an accumulator which will contain a string that is made up of the column values (converted to string using to_string). However, there is no function for converting boolean to string.

Example: Vertex is called v. Three columns are id (Type = INT), name (Type = string) and valid (Type = BOOL).
I need to form a string in the below format and then add this string to an SET accumulator of type STRING.

@@accum += to_string(v.id)+v.name+to_string(v.valid)
But the above concatenation does not work as the to_string function does not take BOOL as arguments.

Any help would be greatly appreciated.

Hi dhavalis,

You can accomplish this with an IF statement. I know it’s not a function like to_string but can be implemented like:

IF v.valid THEN
  @@accum += to_string(v.id)+v.name+"TRUE"
ELSE
  @@accum += to_string(v.id)+v.name+"FALSE"
1 Like