Hi team I have a array which contains multiple Dictionaries or Objects inside that some keys having a list which contains String
Example
["Twice", "Thrice", "Weekly_Plus"]
I want to use “in” Operator whether local accumulator having the value from these 3 or not
is it possible that we can convert it into setAccum of String and then use “in” operator , because only in SetAccum or BagAccum we can use “in” operator?
I tried but giving me an error
(31, 26) Error: Incompatible operand types SetAccum and jsonarray for the operator +=
Thanks @markmegerian for your response here below is the code snippet , just to explain my problem.
here below is the parameter which i am passing while running the GSQL
CREATE QUERY update_group(String str) FOR GRAPH sga_A {
arr = parse_json_array(str);
start = {Profile.*}
foreach cnt in range[0, arr.size()-1] do
IF arr.getJsonObject(cnt).getString("Operation") == "active_group" THEN
foreach ind in range[0,arr.getJsonObject(cnt).getJsonArray("combinations").size()-1] do
key= arr.getJsonObject(cnt).getJsonArray("combinations").getJsonObject(ind).getString("name");
vst_pattern = arr.getJsonObject(cnt).getJsonArray("combinations").getJsonObject(ind).getJsonObject("value").getJsonArray("visit_pattern");
result = SELECT s FROM start:s WHERE s.@visit_pattern IN vst_pattern ACCUM
INSERT into profile_segments(FROM, To) VALUES(s.id, key);
end;
end;
end;
here my question how can I use membership “in” operator
What I know we can’t be able to use “in” operator on json array.
Error: red line on vst_pattern (A container type required while vst_pattern is a JSONARRAY
Hi Team can somebody here , who can help me on this?
is the solution is this that we need to convert the JSONARRAY TO Setaccum so that we can use the membership “in” operator, this one will requires too more logic for this we need to itrerate from JSONARRAY and append to the Setaccum so that we can use membership “in” operator.
result = SELECT s FROM start:s WHERE s.@visit_pattern IN vst_pattern ACCUM
INSERT into profile_segments(FROM, To) VALUES(s.id, key);
can be done like below
result = SELECT s FROM start:s ACCUM
foreach pattern in IN vst_pattern do
case when s.@visit_pattern == pattern then
INSERT into profile_segments(FROM, To) VALUES(s.id, key),
break
end
end;