metabase / metabase/metabase

Is Not Empty Filter adds an unnecessary clause

Open
#55,252 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

.Backend .Team/Querying [DEPRECATED] .Team/QueryingPlatform Difficulty:Easy Querying/Processor Type:New Feature
Dominant language
Clojure
Stars
49.3k
Forks
6.8k
Avg merge
1d 13h
Merged PRs (30d)
653

Description

### Describe the bug

When adding the `Is Not Empty` Filter the generated SQL adds an unnecessary clause

### To Reproduce

1. Go to New -> Question -> Products -> Category is not empty:

Image

The `OR ("PUBLIC"."PRODUCTS"."CATEGORY" IS NULL)` isn't really needed

### Expected behavior

The first condition ensures that CATEGORY is not NULL.
The OR ("CATEGORY" IS NULL) inside the second condition contradicts the outer IS NOT NULL condition.
Since a row cannot be both NULL and NOT NULL, this part effectively does nothing.

So it should be removed

### Logs

None that are relevant

### Information about your Metabase installation

```JSON
1.53 and master
```

### Severity

minor

### Additional context

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue through New -> Question -> Products -> Category is not empty and inspect the generated SQL. Confirm the redundant OR ("CATEGORY" IS NULL) clause, then verify that the resulting query still returns the expected products without that clause.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.