elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
1.26k stars 24.86k forks source link

ESQL: Remove unnecessary project + aggregation with limit in between #98506

Open costin opened 1 year ago

costin commented 1 year ago

Description

The optimizer knows to combine projections or aggregates and projections but only when they are right next to each other. If there's another node in between (sort, limit, filter) it doesn't:

| stats c = count()
| filter c > 10
| limit 10
| keep c

The keep is redundant.

elasticsearchmachine commented 1 year ago

Pinging @elastic/es-ql (Team:QL)

elasticsearchmachine commented 1 year ago

Pinging @elastic/elasticsearch-esql (:Query Languages/ES|QL)

elasticsearchmachine commented 10 months ago

Pinging @elastic/es-analytics-geo (Team:Analytics)