Skip to content

Handling array with boolean literals#16093

Merged
abhishekagarwal87 merged 4 commits intoapache:masterfrom
sreemanamala:boolean-const-array
Mar 12, 2024
Merged

Handling array with boolean literals#16093
abhishekagarwal87 merged 4 commits intoapache:masterfrom
sreemanamala:boolean-const-array

Conversation

@sreemanamala
Copy link
Copy Markdown
Contributor

Description

Handling array with boolean literals like ARRAY[true, false]

Druid appears to be able to convert an array with boolean expressions like this array[added=deleted, added=delta] into a numeric array of 0 and 1: select array[added=deleted, added=delta] from wikipedia

However, select array[true, false] from wikipedia doesn't work.
This PR fixes this.


Key changed/added classes in this PR
  • DruidRexExecutor
  • CalciteArraysQueryTest

This PR has:

  • been self-reviewed.
  • 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.
  • 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.

Copy link
Copy Markdown
Member

@clintropolis clintropolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if (longVal == null) {
resultAsBooleanList.add(null);
} else {
resultAsBooleanList.add(longVal.longValue() > 0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could use Evals.asBoolean here just on the off chance we ever change how we coerce longs into booleans in the native layer, but this is probably safe too

@sreemanamala sreemanamala changed the title Initialise boolean array Handling array with boolean literals Mar 12, 2024
@abhishekagarwal87 abhishekagarwal87 merged commit ef9637e into apache:master Mar 12, 2024
@adarshsanjeev adarshsanjeev added this to the 30.0.0 milestone May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants