elastic / elastic/elasticsearch

SQL: Comparisons of IP type in script and local context use lexical ordering

Open
#85,563 2 comments 0 reactions 0 assignees View on GitHub
:Analytics/SQL >bug Team:Analytics
Dominant language
Java
Stars
77.9k
Forks
26.1k
PR merge metrics
PR metrics pending

Description

### Elasticsearch Version

master

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

OSX

### Problem Description

see example:

```
> select '192.1.1.0'::ip < '20.0.0.1'::ip
'192.1.1.0'::ip < '20.0.0.1'::ip
--------------------------------
true
```

same applies for comparison executed in script context:

```
> select '192.1.1.0'::ip < '20.0.0.1'::ip b from test_emp where b
b
---------------
true
true
true
true
...
```

ip comparisons that are pushed down to the search API work as expected. E.g. `select * from ips where i < '20.0.0.1'::ip`

### Steps to Reproduce

see example queries above

### Logs (if relevant)

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the two SQL examples comparing IP values, including the script/local-context query, and compare their results with the search-API case that already behaves correctly. Trace how IP comparisons are evaluated in local and script contexts; done means all contexts use numeric IP ordering consistently rather than lexical ordering.

Written by the indexing model from the issue text.

Assessment

Tech stack
elasticsearch, sql
Domain
databases, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.