Fix AvgTests error on -0.0 avg#113272
Conversation
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
|
Maybe I'm reading this wrong, but it looks to me like this will accept |
@not-napoleon In ES, I see this: https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html#_which_type_should_i_use (Just above that anchor)
So if ES also allows it, I would allow it too. And for this case, the avg of -0.0 should be -0.0 too (IMO) to be as precise as possible. I don't have an specific opinion on this topic, I'm just basing my thought process on what we currently have (And compatibility with ES) |
not-napoleon
left a comment
There was a problem hiding this comment.
to be as precise as possible.
It's not more precise, it's just more confusing. The IEEE spec for floating points says that the two zeros should be considered equal when possible. Java honors this with it's binary comparison operators (== and friends), but not with Double.equals(). You can read the docs on the double class to get an understanding for why this is the case. Practically, this means that if we start allowing negative zeros in the language, we need to be VERY clear on where they compare via == and where they compare via Double.equals() or Number.equals(). It becomes extremely trappy for users if that behavior is not entirely consistent.
We made the decision early on to not allow -0.0, positive or negative infinity, or NaN as possible values in ESQL. We should be consistent with that here. /cc @costin
It's an input on the test precisely to test that it isn't an output. |
I think we should be consistent with this decision. Our functions should never receive any of those forbidden doubles. We could (should?) add an assertion to the generated code that reads ES might support these but they are all |
Well, the infinities and |
|
Ok, so:
Then, if we have to keep the -0.0 as a potential input in tests, but forbid it as an output, as many functions are currently returning it (Max, MvMax, Min, Values...), I'll fix them by doing a conversion (-0.0 -> 0.0). |
|
@not-napoleon After some checks and talks about this:
|
| } | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| protected final void assertTestCaseResultAndWarnings(Object result) { |
There was a problem hiding this comment.
Javadoc would be nice here.
# Conflicts: # muted-tests.yml
💔 Backport failed
You can use sqren/backport to manually backport by running |
Fixes #113225
Fixes #114175