elastic / elasticsearch

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

SQL: improve the doubles number formatting #39513

Open astefan opened 5 years ago

astefan commented 5 years ago

The doubles number formatting varies between formats. Basically, json is the most "user-friendly" and others should format the numbers the same way.

    sum(salary)     
--------------------
1.7037036724599996E8
{
    "columns": [
        {
            "name": "sum(salary)",
            "type": "double"
        }
    ],
    "rows": [
        [
            170370367.24599996
        ]
    ]
}
---
columns:
- name: "sum(salary)"
  type: "double"
rows:
- - 1.7037036724599996E8
sum(salary)
1.7037036724599996E8
sum(salary)
1.7037036724599996E8
elasticmachine commented 5 years ago

Pinging @elastic/es-search

astefan commented 5 years ago

After some digging, my test was faulty because, apparently, I was using a REST client that re-formatted the json output.

In reality, using curl or the Chrome browser revealed that the output is consistent throughout all formats (which is expected and desirable) and the output is the default Java behavior for formatting numbers:

If m is less than 10-3 or greater than or equal to 107, then it is represented in so-called "computerized scientific notation."

For the time being, we will leave this as is right now, but leave this issue open to record any future desire in this behavior change.

elasticsearchmachine commented 9 months ago

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