@@ -44,8 +44,8 @@ func _resourceWhereV2(e *blockExecutor, bind *RawData, chunk *Chunk, ref uint64,
4444 if err != nil || rref > 0 {
4545 return nil , rref , err
4646 }
47- list := items .Value .([]any )
48- if len (list ) == 0 {
47+ list , ok := items .Value .([]any )
48+ if ! ok || len (list ) == 0 {
4949 return bind , 0 , nil
5050 }
5151
@@ -143,8 +143,8 @@ func resourceSample(e *blockExecutor, bind *RawData, chunk *Chunk, ref uint64) (
143143 if err != nil || rref > 0 {
144144 return nil , rref , err
145145 }
146- list := items .Value .([]any )
147- if len (list ) == 0 {
146+ list , ok := items .Value .([]any )
147+ if ! ok || len (list ) == 0 {
148148 return bind , 0 , nil
149149 }
150150
@@ -169,9 +169,11 @@ func resourceMapV2(e *blockExecutor, bind *RawData, chunk *Chunk, ref uint64) (*
169169 if err != nil || rref > 0 {
170170 return nil , rref , err
171171 }
172- list := items .Value .([]any )
173- if len (list ) == 0 {
174- return bind , 0 , nil
172+ list , ok := items .Value .([]any )
173+ if ! ok || len (list ) == 0 {
174+ // When the input list is empty or not an array(e.g. embedding), return an empty array
175+ // so downstream array operations (e.g., $all) can execute without error.
176+ return & RawData {Type : types .Array (types .Unset ), Value : []any {}}, 0 , nil
175177 }
176178
177179 arg1 := chunk .Function .Args [1 ]
0 commit comments