Skip to content

Support ANY operator #2548

Closed
Closed

Description

@ovr

Hello!

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

// similar to array contains
SELECT 1 = ANY(ARRAY[1,2,3,4])

// negative of array contains
SELECT 1 <> ANY(ARRAY[1,2,3,4])

// Same story for <, <=, >, >=

Thanks

Activity

  1. Jefffrey commented on Sep 20, 2025

    @Jefffrey
    Contributor

    The = case has been implemented by #11849

    Still pending work for the other cases (<, <=, etc.)

  2. Jefffrey commented on Dec 10, 2025

    @Jefffrey
    Contributor

    Some pointers.

    Planner code here, need to wire in support for operators other than =:

    fn plan_any(&self, expr: RawBinaryExpr) -> Result<PlannerResult<RawBinaryExpr>> {
    if expr.op == BinaryOperator::Eq {
    Ok(PlannerResult::Planned(Expr::ScalarFunction(
    ScalarFunction::new_udf(
    array_has_udf(),
    // left and right are reversed here so `needle=any(haystack)` -> `array_has(haystack, needle)`
    vec![expr.right, expr.left],
    ),
    )))
    } else {
    plan_err!("Unsupported AnyOp: '{}', only '=' is supported", expr.op)
    }
    }

    Implementation in here:

    https://github.com/apache/datafusion/blob/2a08013af3ccf703bee202c959b40bb0d35bdea1/datafusion/functions-nested/src/array_has.rs

    • Need to consider how to work it into the existing code and try not to duplicate for all operators if possible

    Add SLT tests here:

    https://github.com/apache/datafusion/blob/2a08013af3ccf703bee202c959b40bb0d35bdea1/datafusion/sqllogictest/test_files/array.slt

  3. buraksenn commented on Mar 9, 2026

    @buraksenn
    Contributor

    take

  4. added a commit that references this issue on Mar 20, 2026
    be273d6
  5. added a commit that references this issue on Mar 21, 2026
    fe38337
  6. added a commit that references this issue on Mar 24, 2026
    f505cb9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions