elastic / elasticsearch

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

ESQL: Metrics create reference attributes in EsRelation #110827

Open alex-spies opened 3 months ago

alex-spies commented 3 months ago

Running LogicalPlanOptimizerTests.testMetricsWithoutRate currently passes, but only because EsRelation.equals ignores the EsRelation's attributes.

Adding && Objects.equals(attrs, other.attrs); to EsRelation.equals shows that the three plans generated by this test deviate.

Inspection shows that

            METRICS k8s count(to_long(network.total_bytes_in)) BY bucket(@timestamp, 1 minute)
            | LIMIT 10

Creates an EsRelation with reference attributes bucket(@timestamp, 1 minute){r}#3 and $$to_long(network>$COUNT$0{r}#19, which the other plans do not have in their EsRelation (the plan's leaf).

This looks concerning, as EsRelations generally should have just field attributes; reference attributes normally refer to something coming from an index, enrich, dissect, grok or lookup.

elasticsearchmachine commented 3 months ago

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

alex-spies commented 3 months ago

Need to mute this in a PR that fixes EsRelation.equals.