Skip to content

ESQL: fix COUNT filter pushdown (#117503)#117654

Merged
elasticsearchmachine merged 2 commits intoelastic:8.17from
bpintea:port/117503_8.17
Nov 28, 2024
Merged

ESQL: fix COUNT filter pushdown (#117503)#117654
elasticsearchmachine merged 2 commits intoelastic:8.17from
bpintea:port/117503_8.17

Conversation

@bpintea
Copy link
Copy Markdown
Contributor

@bpintea bpintea commented Nov 27, 2024

If COUNT agg has a filter applied, this must also be push down to source. This currently does not happen, but this issue is masked currently by two factors:

  • a logical optimisation, ExtractAggregateCommonFilter that extracts the filter out of the STATS entirely (and pushes it to source then from a WHERE);
  • the phisical plan optimisation implementing the push down, PushStatsToSource, currently only applies if there's just one agg function to push down.

However, this fix needs to be applied since:

  • it's still present in versions prior to ExtractAggregateCommonFilter introduction;
  • the defect might resurface when the restriction in PushStatsToSource is lifted.

Fixes #115522.

(cherry picked from commit 560e0c5)

If `COUNT` agg has a filter applied, this must also be push down to source. This currently does not happen, but this issue is masked currently by two factors:
* a logical optimisation, `ExtractAggregateCommonFilter` that extracts the filter out of the STATS entirely (and pushes it to source then from a `WHERE`);
* the phisical plan optimisation implementing the  push down, `PushStatsToSource`, currently only applies if there's just one agg function to push down.

However, this fix needs to be applied since:
* it's still present in versions prior to `ExtractAggregateCommonFilter` introduction;
* the defect might resurface when the restriction in `PushStatsToSource` is lifted.

Fixes elastic#115522.

(cherry picked from commit 560e0c5)
@bpintea bpintea added >bug backport auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Analytics/ES|QL AKA ESQL v8.17.1 labels Nov 27, 2024
@elasticsearchmachine elasticsearchmachine merged commit 80a8102 into elastic:8.17 Nov 28, 2024
@bpintea bpintea deleted the port/117503_8.17 branch November 28, 2024 12:43
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-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) backport >bug v8.17.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants