Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSQ window functions: Fix partition boundary issues for arrays #16780

Merged

Conversation

Akshat-Jain
Copy link
Contributor

Description

Currently, queries like the following give incorrect results:

select countryName, cityName, channel, 
row_number() over (partition by array[1,2,length(cityName)] order by countryName) as c
from wikipedia
where countryName in ('Austria', 'Republic of Korea')
group by countryName, cityName, channel

This is because while calculating the partitioning boundaries, we use Objects.equals() to check the value for partition column. But it returns false when trying to compare [1,2,null] against [1,2,null] because of the presence of null value.

This PR changes the comparison logic to use NullableTypeStrategy for the column type.


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.

@github-actions github-actions bot added Area - Batch Ingestion Area - Querying Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 labels Jul 23, 2024
Copy link
Contributor

@sreemanamala sreemanamala left a comment

Choose a reason for hiding this comment

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

lgtm. added a couple of nit comments. should be fine either way.

@Akshat-Jain Akshat-Jain requested a review from LakshSingla July 23, 2024 10:20
@LakshSingla
Copy link
Contributor

MSQ changes LGTM

@cryptoe cryptoe merged commit a0437b6 into apache:master Jul 24, 2024
88 checks passed
sreemanamala pushed a commit to sreemanamala/druid that referenced this pull request Aug 6, 2024
…e#16780)

* MSQ window functions: Fix partition boundary issues for arrays

* Address review comments

* Cache type strategies

* Trigger Build

* Convert typeStrategies from list to array
@kfaraz kfaraz added this to the 31.0.0 milestone Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area - Batch Ingestion Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 Area - Querying
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants