Hi team, anyone here who can help me on this
TYPEDEF Tuple <STRING label, STRING id> feature_score;
ListAccum<feature_score> @childSegments;
I have a local Accumulator childSegments in my GSQL
and in my Schema i have a vertex segment_type which is connected to multiple seperate segment vertex in schema, below image is the sub part of my schema.
CREATE QUERY types_of_segments(/* Parameters here */) FOR GRAPH clientSiga syntax v2{
/* Write query logic here */
TYPEDEF Tuple <STRING label, STRING id> custom_defined;
ListAccum<custom_defined> @childSegments;
start = {segment_types.*};
results = select s from start:s-(:ee)-:tt ACCUM
IF ee.type == "segment_cv_segment" THEN
s.@childSegments += custom_defined(tt.id, tt.id)
# Here, particular for this IF CASE I want childSegments to be [{"id": "Long Lapsed", "label": "Long Lapsed", "visit_pattern": [], "spend_pattern": [] }, ......]
# these two spend_pattern and visit_pattern are extra
# required only particular for this case
else
# Remaining other cases
# [{"id":"PurchasesInPast6Months", "label": "Purchases in Past 6 Months"}, .......]
s.@childSegments += custom_defined(tt.label, tt.id)
end
ORDER BY s.label ASC;
PRINT results;
}
[
{
"results": [
{
"attributes": {
"@childSegments": [
{
"id": "PurchasesInPast6Months",
"label": "Purchases in Past 6 Months"
}
],
"id": "purchaseTransaction",
"label": "Purchase Transactions",
"params": {}
},
"v_id": "purchaseTransaction",
"v_type": "segment_types"
},
{
"attributes": {
"@childSegments": [
{
"id": "FocusedShopper",
"label": "Focused Shopper"
},
{
"id": "researchers",
"label": "Researchers"
}
],
"id": "sessionSegments",
"label": "Session Segments",
"params": {}
},
"v_id": "sessionSegments",
"v_type": "segment_types"
},
{
"attributes": {
"@childSegments": [
{
"id": "Long Lapsed",
"label": "Long Lapsed",
"spend_pattern": [],
"visit_pattern": []
},
{
"id": "spender",
"label": "Spender",
"spend_pattern": [],
"visit_pattern": []
}
],
"id": "shortLoyalty",
"label": "Short Loyalty",
"params": {}
},
"v_id": "shortLoyalty",
"v_type": "segment_types"
}
]
}
]
In some case I require extra key value pair, here in this code i require spend_pattern and visit_pattern particular for this specific condition
Thanks,