Skip to content

SQL: CONTAINS with an array (not List) right-hand side never matches #6995

Closed

Description

@lvca

Summary

ContainsCondition.execute() only normalizes a plain array (String[], int[], ...) to a List when it appears on the left-hand side of CONTAINS (fixed in #6984 / PR #6993). When the array is on the right-hand side instead, it still falls through to the per-element equalsInContainsSpace(o, right) loop, which compares each left-hand element against the whole array object - so the condition is essentially always false.

Repro

SELECT ('a b c'.split(' ') CONTAINS 'x y'.split(' '))

'x y'.split(' ') is a String[], so it never equals any of ['a','b','c']'s elements - the condition returns false even for overlapping content, and there's no working way to express "these two split() results share an element" without wrapping one side in a list-producing function.

Where

engine/src/main/java/com/arcadedb/query/sql/parser/ContainsCondition.java, execute(Object, Object) - the right instanceof Collection check (and the right instanceof Iterable fallback below it) both miss a plain array, same root cause as #6984 but on the other side of the operator.

Suggested fix

Normalize right the same way #6993 normalizes left: if right is an array, convert it to a List before the existing Collection/Iterable branches run.

Filed as a follow-up noted during review of PR #6993 (out of scope for #6984, which only reported the left-hand-side case).

Activity

  1. added a commit that references this issue on Sep 1, 2026
  2. added this to the 26.9.1 milestone on Sep 2, 2026
  3. added
    in progressThe team is actively working on this issue
    on Sep 2, 2026
  4. self-assigned this
    on Sep 2, 2026
  5. added 2 commits that reference this issue on Sep 2, 2026
  6. removed
    in progressThe team is actively working on this issue
    on Sep 3, 2026
  7. lvca commented on Sep 3, 2026

    @lvca
    MemberAuthor

    Fixed in #7079, shipping in 26.9.1.

    CONTAINS now treats an array on the right the same as the equivalent list, so 'a b c'.split(' ') CONTAINS 'a'.split(' ') and a parameter bound to a Java array both work instead of never matching.

    Note the meaning of CONTAINS with a collection on the right is unchanged: a single-item collection is unwrapped and its item looked up, while a longer one is searched for as one element of the left-hand list (tags CONTAINS ['a','b'] matches a row whose tags contains the list ['a','b']). To test membership of several values, use one condition per value.

    One deliberate exception: a BINARY value on the right stays a single value, so list CONTAINS :binary still searches for that binary rather than for its bytes.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions