Skip to content

ES|QL: Fix ABSENT/PRESENT on agg with false filter#139609

Merged
dimitris-athanasiou merged 3 commits intoelastic:mainfrom
dimitris-athanasiou:fix-esql-present/absent-on-stats-with-false-filter
Dec 16, 2025
Merged

ES|QL: Fix ABSENT/PRESENT on agg with false filter#139609
dimitris-athanasiou merged 3 commits intoelastic:mainfrom
dimitris-athanasiou:fix-esql-present/absent-on-stats-with-false-filter

Conversation

@dimitris-athanasiou
Copy link
Contributor

This query

ROW a = 42
| STATS ABSENT(a) WHERE FALSE

currently returns null.

However, it should return true for ABSENT, or false for PRESENT.

This fixes this bug. The problem is that we have a rule for replacing aggs with false filter with an eval: ReplaceStatsFilteredAggWithEval. That rule needs to be updated to handle ABSENT/PRESENT in order to provide the correct value for those functions instead of null.

Relates #131069

This query

```
ROW a = 42
| STATS ABSENT(a) WHERE FALSE
```

currently returns `null`.

However, it should return `true` for `ABSENT`, or `false` for `PRESENT`.

This fixes this bug. The problem is that we have a rule for replacing
aggs with false filter with an eval: `ReplaceStatsFilteredAggWithEval`.
That rule needs to be updated to handle `ABSENT/PRESENT` in order to provide
the correct value for those functions instead of `null`.

Relates elastic#131069
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Dec 16, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@elasticsearchmachine
Copy link
Collaborator

Hi @dimitris-athanasiou, I've created a changelog YAML for you.

Copy link
Contributor

@leontyevdv leontyevdv left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for fixing this @dimitris-athanasiou!

@dimitris-athanasiou dimitris-athanasiou added the auto-backport Automatically create backport pull requests when merged label Dec 16, 2025
@dimitris-athanasiou dimitris-athanasiou merged commit c77fb96 into elastic:main Dec 16, 2025
35 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 139609

@dimitris-athanasiou
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
9.2

Questions ?

Please refer to the Backport tool documentation

dimitris-athanasiou added a commit to dimitris-athanasiou/elasticsearch that referenced this pull request Dec 18, 2025
This query

```
ROW a = 42
| STATS ABSENT(a) WHERE FALSE
```

currently returns `null`.

However, it should return `true` for `ABSENT`, or `false` for `PRESENT`.

This fixes this bug. The problem is that we have a rule for replacing
aggs with false filter with an eval: `ReplaceStatsFilteredAggWithEval`.
That rule needs to be updated to handle `ABSENT/PRESENT` in order to provide
the correct value for those functions instead of `null`.

Relates elastic#131069

(cherry picked from commit c77fb96)

# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
dimitris-athanasiou added a commit that referenced this pull request Dec 18, 2025
This query

```
ROW a = 42
| STATS ABSENT(a) WHERE FALSE
```

currently returns `null`.

However, it should return `true` for `ABSENT`, or `false` for `PRESENT`.

This fixes this bug. The problem is that we have a rule for replacing
aggs with false filter with an eval: `ReplaceStatsFilteredAggWithEval`.
That rule needs to be updated to handle `ABSENT/PRESENT` in order to provide
the correct value for those functions instead of `null`.

Relates #131069

(cherry picked from commit c77fb96)
@dimitris-athanasiou dimitris-athanasiou deleted the fix-esql-present/absent-on-stats-with-false-filter branch December 18, 2025 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL auto-backport Automatically create backport pull requests when merged backport pending >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.2.4 v9.3.0

3 participants