druid icon indicating copy to clipboard operation
druid copied to clipboard

Array overlap to allow numeric operand

Open sreemanamala opened this issue 1 year ago • 1 comments

Description

Allow ARRAY_OVERLAP operator to take numeric value as input Allow null & double values as elements of array passed as sql parameter

Release note


Key changed/added classes in this PR
  • ArrayOverlapOperatorConversion
  • SqlParameterizerShuttle
  • CalciteArraysQueryTest

This PR has:

  • [x] been self-reviewed.
    • [ ] using the concurrency checklist (Remove this item if the PR doesn't have any relation to concurrency.)
  • [ ] added documentation for new or modified features or behaviors.
  • [ ] a release note entry in the PR description.
  • [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • [ ] added or updated version, license, or notice information in licenses.yaml
  • [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • [x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • [ ] added integration tests.
  • [ ] been tested in a test Druid cluster.

sreemanamala avatar Feb 26 '24 01:02 sreemanamala

i think the only hesitation i have here is it feels odd that this is the only array function that allows numeric inputs, i wonder if we should just allow them all to accept any input since at the native layer we allow the array functions to work with anything, if it isn't already and array we make it a single element array. This is largely done to make stuff work with schema evolution, and also mvds fit this pattern, but SQL is currently more restrictive.. and probably shouldn't have allowed VARCHAR either if we werent going to allow ANY to be symmetrical with the native layer.

Need to think about it a bit.

clintropolis avatar Mar 14 '24 10:03 clintropolis

IMO, rather than expanding the ARRAY functions to accept various kinds of scalars in array context, it's better to introduce a new function that explicitly accepts a scalar + an array. You're doing that already in #16306, so perhaps we can close this one?

gianm avatar Apr 18 '24 22:04 gianm