Skip to content

feat(postgres)!: preserve x IS NOT NULL instead of normalizing to NOT x IS NULL#7938

Open
geooo109 wants to merge 2 commits into
mainfrom
geooo109/is_not_null
Open

feat(postgres)!: preserve x IS NOT NULL instead of normalizing to NOT x IS NULL#7938
geooo109 wants to merge 2 commits into
mainfrom
geooo109/is_not_null

Conversation

@geooo109

Copy link
Copy Markdown
Collaborator

Fixes #7909

Comment thread sqlglot/optimizer/simplify.py
Comment thread sqlglot/dialects/dialect.py Outdated
Comment thread sqlglot/dialects/dialect.py Outdated
Comment thread sqlglot/dialects/materialize.py Outdated
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

SQLGlot Integration Test Results

✅ All tests passed

Comparing:

  • this branch (sqlglot:geooo109/is_not_null @ sqlglot 305e073)
  • baseline (main @ sqlglot a7725f2)

Overall

main: 192414 total, 153544 passed (pass rate: 79.8%)

sqlglot:geooo109/is_not_null: 180220 total, 142392 passed (pass rate: 79.0%)

Transitions:
No change

Dialect pair changes: 0 previous results not found, 3 current results not found

✅ All tests passed

Comment thread sqlglot/generator.py

This comment was marked as resolved.

Comment on lines +897 to +898
if any(isinstance(e, exp.Is) and e.args.get("negate") for e in (left, right)):
return None

@georgesittas georgesittas Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

To provide some extra context: even if we let Is with negate set to True fall through to the rest of the logic, it would effectively result in a no-op, because this arg is only set for NULL operands today and Null doesn't satisfy any of the following branches: is_number is false, is_string is false, and extract_date() returns None; so the function returns None without modifying the subtree.

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.

x IS NOT NULL normalized to NOT x IS NULL changes results for row-valued expressions (postgres round-trip)

3 participants