Skip to content

Conversation

@seawinde
Copy link
Contributor

@seawinde seawinde commented Nov 10, 2025

picked from #56942

…niform when group sets exist (apache#56942)

Fix not in aggregate's output err after eliminate by uniform when group
sets exist

if query as following, would cause `ERROR 1105 (HY000): errCode = 2,
detailMessage = GROUPING_PREFIX_event_name_group not in aggregate's
output`

the pr fix this

```sql
SELECT
  CASE WHEN GROUPING(event_date) = 1 THEN '(TOTAL)' ELSE CAST(event_date AS VARCHAR) END AS event_date,
  user_id,
  MAX(conversion_level) AS conversion_level,
  CASE WHEN GROUPING(event_name_group) = 1 THEN '(TOTAL)' ELSE event_name_group END AS event_name_group
FROM
  (
    SELECT
      src.event_date,
      src.user_id,
      WINDOW_FUNNEL(
        3600 * 24 * 1,
        'default',
        src.event_time,
        src.event_name = 'shop_buy',
        src.event_name = 'shop_buy'
      ) AS conversion_level,
      src.event_name_group
    FROM
      (
        SELECT
          CAST(etb.`@dt` AS DATE) AS event_date,
          etb.`@event_name` AS event_name,
          etb.`@event_time` AS event_time,
          etb.`@event_name` AS event_name_group,
          etb.`@user_id` AS user_id
        FROM
          `test_event` AS etb
        WHERE
          etb.`@dt` between '2025-09-03 02:00:00' AND '2025-09-10 01:59:59'
          AND etb.`@event_name` = 'shop_buy'
          AND etb.`@user_id` IS NOT NULL
          AND etb.`@user_id` > '0'
      ) AS src
    GROUP BY
      src.event_date,
      src.user_id,
      src.event_name_group
  ) AS fwt
GROUP BY
  GROUPING SETS (
    (user_id),
    (user_id, event_date),
    (user_id, event_name_group),
    (user_id, event_date, event_name_group)
  );
```

### What problem does this PR solve?

Issue Number: close #xxx

Related PR: apache#43391 

Problem Summary:

### Release note

None

### Check List (For Author)

- Test <!-- At least one of them must be included. -->
    - [ ] Regression test
    - [ ] Unit Test
    - [ ] Manual test (add detailed scripts or steps below)
    - [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
        - [ ] Previous test can cover this change.
        - [ ] No code files have been changed.
        - [ ] Other reason <!-- Add your reason?  -->

- Behavior changed:
    - [ ] No.
    - [ ] Yes. <!-- Explain the behavior change -->

- Does this need documentation?
    - [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
apache/doris-website#1214 -->

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
@seawinde seawinde requested a review from yiguolei as a code owner November 10, 2025 11:42
@hello-stephen
Copy link
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@seawinde
Copy link
Contributor Author

run buildall

@yiguolei yiguolei closed this Nov 11, 2025
@yiguolei yiguolei reopened this Nov 11, 2025
@morrySnow morrySnow changed the title [fix](nereids) Fix not in aggregate's output err after eliminate by uniform when group sets exist (#56942) branch-4.0: [fix](nereids) Fix not in aggregate's output err after eliminate by uniform when group sets exist #56942 Nov 11, 2025
@yiguolei yiguolei merged commit 64ce962 into apache:branch-4.0 Nov 11, 2025
29 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants