Slackbot
05/05/2023, 8:00 PMSergio Ferragut
05/05/2023, 10:33 PMgroupByEnableMultiValueUnnesting which is part of the group by query context options found here. I tested it on 25.0 and it is working, it even respects your choice of MV behavior at ingestion, I tested with ARRAY to see that it respected the order of the elements, and distinguished between different orders when grouping:
inline data:
{"mv_column":["a","b","c"],"metric":1}
{"mv_column":["d","a","b"],"metric":3}
{"mv_column":["b","a","d"],"metric":5}
query context:
{
"groupByEnableMultiValueUnnesting": "false"
}
SQL:
SELECT "mv_column", count(*) FROM "inline_data" GROUP BY 1
Results:Sergio Ferragut
05/05/2023, 10:35 PMSELECT MV_TO_ARRAY("mv_column"), count(*) FROM "inline_data" GROUP BY 1
Now it works:Sergio Ferragut
05/05/2023, 10:38 PMSergio Ferragut
05/05/2023, 10:51 PMSELECT MV_TO_ARRAY("mv_column"), SUM("metric"), count(*)
FROM "inline_data"
WHERE MV_TO_STRING("mv_column",100) like '%c%'
GROUP BY 1
and this:
SELECT MV_TO_ARRAY("mv_column"), SUM("metric"), count(*)
FROM "inline_data"
WHERE "mv_column" like '%c%'
GROUP BY 1
and both worked.
After rereading your question I see that what you want is that only the item that matches be in the results, not the other items in the row that matched. This will at least give you the right number of rows, even though it still shows the other values in the MV column:
SELECT MV_TO_ARRAY("mv_column"), SUM("metric"), count(*)
FROM "inline_data"
WHERE "mv_column" like '%c%'
GROUP BY 1Sergio Ferragut
05/05/2023, 11:11 PMSELECT n."mv_item", SUM("metric"), count(*)
FROM "inline_data",
UNNEST("mv_column") AS n("mv_item")
WHERE n."mv_item" like '%d%'
GROUP BY 1Vadim
05/06/2023, 12:38 AMgroupByEnableMultiValueUnnesting is only for (native) groupBy, the first query you, @Sergio Ferragut, wrote planned to a topNVadim
05/06/2023, 12:39 AMVadim
05/06/2023, 12:39 AMMV_TO_ARRAY(...)Ben Krug
05/06/2023, 2:35 AMMV_FILTER_ONLY. (See here._)Vadim
05/06/2023, 3:28 AMIN filter, not a LIKE filterBharat Thakur
05/06/2023, 7:55 AMBharat Thakur
05/06/2023, 7:55 AMSergio Ferragut
05/06/2023, 5:22 PMRenato Santos
05/08/2023, 1:07 AM