Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Inaccurate results for LOG10 function #297

Closed
abbashus opened this issue Nov 20, 2019 · 1 comment
Closed

Inaccurate results for LOG10 function #297

abbashus opened this issue Nov 20, 2019 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@abbashus
Copy link
Contributor

The results for LOG10 function are not accurate. In the below example it should be 3 instead of 2.9999....6

GET /_opendistro/_sql/?format=jdbc
{
  "query": """
  SELECT FlightNum, LOG10(1000) as somealias
  FROM kibana_sample_data_flights 
 
  """
}

Result:
   [
      "2TWHRUP",
      2.9999999999999996
    ],

--------------------------------------
Similarly for raw ES result:

GET /_opendistro/_sql/?
{
  "query": """
  SELECT FlightNum, LOG10(1000) as somealias
  FROM kibana_sample_data_flights 
 
  """
}

Result:

"fields" : {
   "somealias" : [
     2.9999999999999996
   ]
 }

@abbashus abbashus added the bug Something isn't working label Nov 20, 2019
@chloe-zh
Copy link
Member

That was because the log functions loga(b) were implemented directly using Math.log(b)/Math.log(b), which introduces some inaccuracy. I went into the painless API and found it supports Math.log10, so I made a quick fix, along with LOG and LN.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants