Check the following query if that works for your case
SELECT meta(doc).id AS id,
doc.dispatchTime,
crew.firstName,
crew.lastName,
crew.userKey as key,
doc.tenantKey,
REPLACE(REPLACE(
REPLACE(ENCODE_JSON(roles),
"\",\"",
""),
"[\"",
""),
"\"]",
"") AS roles
FROM `bucket` doc
UNNEST doc.crewMembers AS crew
LET roles = crew.roles[*].`value`;
SELECT
REPLACE(REPLACE(
REPLACE(ENCODE_JSON(["a","b","c"]),
"\",\"",
""),
"[\"",
""),
"\"]",
"");
Alternative :
The looping construct will not use previous values.
If you know upfront approximately how many elements you have in array can do this.
SELECT meta(doc).id AS id,
doc.dispatchTime,
crew.firstName,
crew.lastName,
crew.userKey as key,
doc.tenantKey,
IFMISSINGORNULL(roles[0],"") || IFMISSINGORNULL(roles[1],"") || IFMISSINGORNULL(roles[2],"") AS roles
FROM `bucket` doc
UNNEST doc.crewMembers AS crew
LET roles = crew.roles[*].`value`;
Repeat IFMISSINGORNULL(roles[num],"") maximum you think you have.
Opened Feature Improvement MB-27281