I'm working on a migration project (MongoDB to Snowflake) and trying to convert one of the mongo queries to Snowflake, we have a use case to fetch records if all the elements from an array matched based on the given parameters.
Mongo DB Function: $all
The $all operator selects the documents where the value of a field is an array that contains all the specified elements.
Mongo Query:
db.collection('collection_name').find({
'code': { '$in': [ 'C0001' ] },
'months': { '$all': [ 6, 7, 8, 9 ] } --> 6,7,8,9 given parameters
});
Table Structure in snowflake:
column name datatype
code varchar(50)
id int
months ARRAY
weeks ARRAY
Could you provide some suggestions on how to write this query in Snowflake? Any recommendations would be helpful.