MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / ArrayOverlaps

Function ArrayOverlaps

pkg/sql/sem/tree/eval.go:387–407  ·  view source on GitHub ↗

ArrayOverlaps return true if there is even one element common between the left and right arrays.

(
	ctx context.Context, cmpCtx CompareContext, array, other *DArray,
)

Source from the content-addressed store, hash-verified

385// ArrayOverlaps return true if there is even one element
386// common between the left and right arrays.
387func ArrayOverlaps(
388 ctx context.Context, cmpCtx CompareContext, array, other *DArray,
389) (*DBool, error) {
390 if !array.ParamTyp.Equivalent(other.ParamTyp) {
391 return nil, pgerror.New(pgcode.DatatypeMismatch, "cannot compare arrays with different element types")
392 }
393 for _, needle := range array.Array {
394 // Nulls don't compare to each other in && syntax.
395 if needle == DNull {
396 continue
397 }
398 for _, hay := range other.Array {
399 if cmp, err := needle.Compare(ctx, cmpCtx, hay); err != nil {
400 return DBoolFalse, err
401 } else if cmp == 0 {
402 return DBoolTrue, nil
403 }
404 }
405 }
406 return DBoolFalse, nil
407}
408
409// JSONExistsAny return true if any value in dArray is exist in the json
410func JSONExistsAny(json DJSON, dArray *DArray) (*DBool, error) {

Callers

nothing calls this directly

Calls 3

NewFunction · 0.92
EquivalentMethod · 0.80
CompareMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…