Skip to content

fix(query): preserve nullable reflexive equality filters - #20390

Draft
youngsofun wants to merge 1 commit into
databendlabs:mainfrom
youngsofun:codex/fix-20379
Draft

fix(query): preserve nullable reflexive equality filters#20390
youngsofun wants to merge 1 commit into
databendlabs:mainfrom
youngsofun:codex/fix-20379

Conversation

@youngsofun

@youngsofun youngsofun commented Aug 26, 2026

Copy link
Copy Markdown
Member

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Validation performed:

  • cargo fmt --all -- --check
  • TEST_SUBDIR=regressions cargo test --package databend-common-sql --test it -- planner::test_lite_replay_service_optimizer_cases --exact --nocapture
  • TEST_SUBDIR=regressions cargo test --package databend-query --test it -- sql::planner::optimizer::optimizer_test::test_optimizer --exact --nocapture
  • TEST_SUBDIR=tpcds cargo test --package databend-common-sql --test it -- planner::test_lite_replay_service_optimizer_cases --exact --nocapture
  • cargo clippy --package databend-common-sql --tests -- -D warnings

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

Risk and performance

The optimizer only retains the original x = x predicate when x is nullable. Non-nullable self-equalities still take the existing elimination path, and other equality inference is unchanged. Retaining the nullable predicate can also push the required NULL rejection closer to a scan.

AI assistance

  • AI usage: A coding agent diagnosed the filter-inference bug, drafted the minimal optimizer fix, investigated affected optimizer snapshots, and added logic and optimizer regression coverage.
  • Responsible human: @youngsofun
  • The responsible human has read every line of this diff and can explain each change

This change is Reviewable

@github-actions github-actions Bot added the pr-bugfix this PR patches a bug in codebase label Aug 26, 2026
@youngsofun
youngsofun marked this pull request as draft August 26, 2026 10:57
@youngsofun
youngsofun force-pushed the codex/fix-20379 branch 2 times, most recently from 5ea9be5 to 9f0a01f Compare August 26, 2026 12:39
@youngsofun
youngsofun marked this pull request as ready for review August 26, 2026 12:40
@youngsofun
youngsofun requested a review from b41sh August 26, 2026 12:40

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f0a01fcaa

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@youngsofun
youngsofun force-pushed the codex/fix-20379 branch 3 times, most recently from 9f7f3e7 to 1555e80 Compare August 27, 2026 06:28
@youngsofun
youngsofun requested a review from zhang2014 August 28, 2026 07:32
@youngsofun
youngsofun marked this pull request as draft August 28, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix this PR patches a bug in codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: HAVING (AGG(col) = AGG(col)) keeps groups whose aggregate is NULL — the same self-comparison in a projection column filters them correctly

1 participant