Skip to content

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

Merged
geooo109 merged 2 commits into
mainfrom
geooo109/is_not_null
Jul 27, 2026
Merged

feat(postgres)!: preserve x IS NOT NULL instead of normalizing to NOT x IS NULL#7938
geooo109 merged 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.

@geooo109
geooo109 merged commit 2aae7f7 into main Jul 27, 2026
8 checks passed
@geooo109
geooo109 deleted the geooo109/is_not_null branch July 27, 2026 08:33
PiyaDaswadkar pushed a commit to PiyaDaswadkar/sqlglot that referenced this pull request Jul 29, 2026
… x IS NULL (tobymao#7938)

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

* PR feedback 1 (george)
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