Skip to content

[BugFix] Fix list partition pruning of multi-value partitions containing NULL (backport #78946) - #78962

Open
mergify[bot] wants to merge 1 commit into
branch-4.1from
mergify/bp/branch-4.1/pr-78946
Open

[BugFix] Fix list partition pruning of multi-value partitions containing NULL (backport #78946)#78962
mergify[bot] wants to merge 1 commit into
branch-4.1from
mergify/bp/branch-4.1/pr-78946

Conversation

@mergify

@mergify mergify Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Why I'm doing:

ListPartitionPruner prunes !=, NOT IN and IS NOT NULL by allPartitions - nullPartitions, but nullPartitions holds every partition whose value list contains NULL. A multi-value partition like VALUES IN ("beijing", NULL) is dropped as a whole and its non-null rows are lost. An equi join derives col IS NOT NULL on the join key, so JOIN ... ON f.city = d.city hits it too.

CREATE TABLE fact (k INT, city VARCHAR(20))
PARTITION BY LIST (city) (
    PARTITION pmix VALUES IN ('beijing', NULL),
    PARTITION psh  VALUES IN ('shanghai'));
INSERT INTO fact VALUES (1, NULL), (2, 'beijing'), (3, 'shanghai');

SELECT k, city FROM fact WHERE city IS NOT NULL;   -- beijing is lost
SELECT k, city FROM fact WHERE city != 'shanghai'; -- empty

What I'm doing:

Only drop NULL-only partitions for null-rejecting predicates: a partition is removed only if it is in nullPartitions and holds a single value (isSingleValuePartition), the same guard the literal removal already uses. External tables (no ListPartitionInfo) are unchanged since each partition holds one value. IS NULL and <=> NULL keep using the "contains NULL" set.

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
    • This pr needs auto generate documentation
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 4.1
    • 4.0
    • 3.5

This is an automatic backport of pull request #78946 done by [Mergify](https://mergify.com).

…ing NULL (#78946)

Signed-off-by: Jason_Qu <88529388+JasonQu1@users.noreply.github.com>
(cherry picked from commit a4d5952)
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.

1 participant