Skip to content

[fix](case) one_col_range_partition: query a date range that has data#64523

Open
shuke987 wants to merge 1 commit into
apache:branch-4.1from
shuke987:fix-one-col-range-partition-casewhen-prune
Open

[fix](case) one_col_range_partition: query a date range that has data#64523
shuke987 wants to merge 1 commit into
apache:branch-4.1from
shuke987:fix-one-col-range-partition-casewhen-prune

Conversation

@shuke987

Copy link
Copy Markdown
Collaborator

Problem

one_col_range_partition fails on branch-4.1 P0 at the multi-branch CASE WHEN assertion (~line 256). The CASE WHEN simplifies to dt >= '2021-05-01', but the table's data only spans 2020-01-01 ~ 2021-02-20 (10000 hours), so that range contains no data. The optimizer now correctly prunes the all-empty partitions to 0:VEMPTYSET, so the stale contains("partitions=417/1826") no longer matches.

This is not a correctness bug — the result is correct (0 rows, nothing matches). Verified on a branch-4.1 cluster:

  • a plain WHERE dt >= '2021-05-01' also prunes to VEMPTYSET (data-driven empty-partition pruning);
  • inserting a row dt = '2021-06-15' immediately flips the plan to partitions=1/1826 and the row is returned — so VEMPTYSET never drops real data.

Fix

Change the CASE WHEN's second threshold to '2021-1-15' (inside the data range) so it prunes to a real, non-empty partition set, and update the expected count to partitions=37/1826. This keeps the assertion verifying that a multi-branch CASE WHEN is correctly pushed into partition pruning.

Scope check: this is the only stale assertion in the suite — the sibling CASE WHEN near line 261 still yields 417/1826 and is left unchanged.

Verification

On a branch-4.1 cluster the rewritten CASE WHEN deterministically prunes to partitions=37/1826 (matching dt >= '2021-01-15').

🤖 Generated with Claude Code

The CASE WHEN at this assertion simplifies to `dt >= '2021-05-01'`, but the table's
data only spans 2020-01-01 ~ 2021-02-20 (10000 hours), so that range contains no data.
The optimizer now correctly prunes the all-empty partitions to VEMPTYSET (verified: a
plain `dt >= '2021-05-01'` prunes the same way, and inserting a matching row immediately
makes it scan that partition and return the row), so the stale `partitions=417/1826`
expectation no longer holds. This is not a correctness bug -- the result is correct
(0 rows, nothing matches). Change the threshold to '2021-1-15' (within the data range)
so the CASE WHEN prunes to a real, non-empty partition set; update the expected count to
37/1826. Scope check: this is the only stale assertion in the suite (the sibling CASE
WHEN near line 261 still yields 417/1826 and is left unchanged).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@shuke987 shuke987 requested a review from yiguolei as a code owner June 15, 2026 08:31
@shuke987

Copy link
Copy Markdown
Collaborator Author

run buildall

@hello-stephen

Copy link
Copy Markdown
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?

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.

2 participants