Skip to content

[CALCITE-6787] Simplification process fails to remove the 'is not null' predicate - #5435

Open
xuzifu666 wants to merge 2 commits into
apache:mainfrom
xuzifu666:calcite-6787
Open

xuzifu666 wants to merge 2 commits into
apache:mainfrom
xuzifu666:calcite-6787

Conversation

@xuzifu666

Copy link
Copy Markdown
Member

@shihchengwei-lab

Copy link
Copy Markdown

With $0 = NULL, expandSearch changes the result of NOT(nullAsFalseSearch) from TRUE to NULL, so a filter drops a row it previously kept.

I reproduced this at 85f38af by wrapping nullAsFalseSearch from testExpandSearchUnknownAs in NOT and calling expandSearch(rexBuilder, null, original, -1, RexUnknownAs.FALSE). RexInterpreter returned:

Before: NOT(SEARCH($0, Sarg[[0..100]; NULL AS FALSE])) => TRUE
After:  NOT(AND(>=($0, 0), <=($0, 100)))              => NULL

Could the shuttle preserve the inner SEARCH’s null behavior when it descends through NOT?

I used AI to help trace the change and run this API-level test. I didn’t test the Hive SQL path.

@xuzifu666

Copy link
Copy Markdown
Member Author

The current issue should be fixed now; could you take a look and review it when you have a moment? @mihaibudiu

@sonarqubecloud

Copy link
Copy Markdown

@mihaibudiu

Copy link
Copy Markdown
Contributor

Shouldn't @shihchengwei-lab check that the objections are addressed?

@shihchengwei-lab

Copy link
Copy Markdown

Thanks for the follow-up. I checked 5f3e41e: with $0 = NULL, NOT(SEARCH(...)) and its expanded form both return TRUE. The focused test passed on JDK 21, and this addresses my original API-level concern.

AI assistance: Codex helped inspect the fix and run the test.

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