Skip to content

ESQL: Union Types Support (take1)#106885

Closed
craigtaverner wants to merge 2 commits intoelastic:mainfrom
craigtaverner:union_types
Closed

ESQL: Union Types Support (take1)#106885
craigtaverner wants to merge 2 commits intoelastic:mainfrom
craigtaverner:union_types

Conversation

@craigtaverner
Copy link
Copy Markdown
Contributor

If the query sources multiple indexes, and the same field exists in multiple indexes with different types, this would normally fail the query. However, if the query includes a conversion function to resolve the field to a single type before it is used in other functions or aggregations, then this should work.

The following query works in this first prototype:

FROM sample_data*
| EVAL client_ip = TO_IP(client_ip)
| STATS count=count(*) BY client_ip
| SORT count DESC, client_ip ASC
| KEEP count, client_ip

The client_ip field is an IP in the sample_data index, but a keyword in the sample_data_str index. Before the aggregation can work, we need to covert all client_ip fields into IP type.

Fixes #100603

@craigtaverner craigtaverner added >feature Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL v8.14.0 labels Mar 28, 2024
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Hi @craigtaverner, I've created a changelog YAML for you.

If the query sources multiple indexes, and the same field exists in multiple indexes with different types, this would normally fail the query. However, if the query includes a conversion function to resolve the field to a single type before it is used in other functions or aggregations, then this should work.

The following query works in this first prototype:

```
FROM sample_data*
| EVAL client_ip = TO_IP(client_ip)
| STATS count=count(*) BY client_ip
| SORT count DESC, client_ip ASC
| KEEP count, client_ip
```

The client_ip field is an `IP` in the `sample_data` index, but a `keyword` in the `sample_data_str` index. Before the aggregation can work, we need to covert all `client_ip` fields into `IP` type.
@craigtaverner craigtaverner changed the title ESQL: Union Types Support ESQL: Union Types Support (take1) Apr 9, 2024
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Hi @craigtaverner, I've created a changelog YAML for you.

@craigtaverner
Copy link
Copy Markdown
Contributor Author

We're focusing on the second prototype now: #107255

@craigtaverner craigtaverner mentioned this pull request Apr 16, 2024
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >feature Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.14.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ESQL: Mismatching mapping cannot be worked around with eval (Support for union types)

2 participants