elastic / elasticsearch

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

ESQL: operators and functions returning Infinite for Doubles #111026

Open ivancea opened 3 months ago

ivancea commented 3 months ago

Some functions return infinite when doubles overflow. Example (All of them result in Inf/-Inf):

ROW a = [1.79769313486231570e+308, 1.79769313486231570e+308]
| STATS sum=SUM(a)
| EVAL
  a = [1.79769313486231570e+308, 1.79769313486231570e+308],
  b = 1.79769313486231570e+308,
  c = -1.79769313486231570e+308,
  mvsum=mv_sum(a), add=b+b, sub=c-b, mul=b*2
| DROP a, b, c
{
  "columns": [
    {
      "name": "sum",
      "type": "double"
    },
    {
      "name": "mvsum",
      "type": "double"
    },
    {
      "name": "add",
      "type": "double"
    },
    {
      "name": "sub",
      "type": "double"
    },
    {
      "name": "mul",
      "type": "double"
    }
  ],
  "values": [
    [
      "Infinity",
      "Infinity",
      "Infinity",
      "-Infinity",
      "Infinity"
    ]
  ]
}

Looks like some remains of https://github.com/elastic/elasticsearch/issues/98698

Functions to fix

elasticsearchmachine commented 3 months ago

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

ivancea commented 3 months ago

The SUM() aggregation fix could depend on the improvements listed in https://github.com/elastic/elasticsearch/issues/110443 around the Warnings object.

As SUM depends on MvSum (surrogation), so both should be fixed at the same time to avoid a having different result if folded