Skip to content

Handle dimensionless group by queries with partitioning#14522

Merged
cryptoe merged 1 commit intoapache:masterfrom
LakshSingla:msq-time-post-agg
Jul 7, 2023
Merged

Handle dimensionless group by queries with partitioning#14522
cryptoe merged 1 commit intoapache:masterfrom
LakshSingla:msq-time-post-agg

Conversation

@LakshSingla
Copy link
Contributor

@LakshSingla LakshSingla commented Jul 4, 2023

Description

In MSQ, queries of the following sorts fail:

INSERT INTO foo1 
SELECT DATE_TRUNC('DAY', CURRENT_TIMESTAMP - INTERVAL '1'DAY) AS __time, SUM(m1) AS sum_m1
FROM foo
PARTITIONED BY DAY

This is a bug in the GroupByQueryKit because the absence of the dimensions causes the query kit to push everything into a single partition (using GlobalSortMaxCountShuffleSpec) however this shuffle spec doesn't support "buckets", which is needed in case the PARTITIONED BY is present.

The fix involves adding an additional check to ensure that the bucketing is not present in the clustering columns.

Note 1: There can be multiple fixes for the above, and the current code should have worked as well if there was no sanity check in the GlobalSortMaxCountShuffleSpec class since we will ultimately get a single row in all the cases.

Note 2: The query would fail if the time was populated by an aggregator instead of a post-aggregator (expression)


Key changed/added classes in this PR
  • GroupByQueryKit

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.

@cryptoe cryptoe added this to the 27.0 milestone Jul 5, 2023
@cryptoe cryptoe added Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 Bug labels Jul 5, 2023
Copy link
Contributor

@adarshsanjeev adarshsanjeev left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@cryptoe cryptoe left a comment

Choose a reason for hiding this comment

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

LGTM

@cryptoe cryptoe merged commit 9e61737 into apache:master Jul 7, 2023
@abhishekagarwal87 abhishekagarwal87 changed the title [MSQ] Handle dimensionless group by queries with partitioning Handle dimensionless group by queries with partitioning Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants