New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected behaviour of Max(<float column>) if first row contains NAN [CORE2160] #2591
Comments
Commented by: Paul Faid (pfaid) I've attached a db backup that helps illustrate the problem. |
Modified by: Paul Faid (pfaid)Attachment: maxnantest.fbk [ 11141 ] |
Commented by: Sean Leyne (seanleyne) If you mean by "NAN" that the value is "NULL" (which is the correct SQL term), then what you are seeing is functionality which <B>explicitly meets the SQL Standard</B>. "NULL" is not a value but a state, as such any operation/function applied to a NULL value will always yield a NULL. So, a SUM of a field which has 1 or more NULL value will always return NULL. |
Modified by: Sean Leyne (seanleyne)status: Open [ 1 ] => Resolved [ 5 ] resolution: Won't Fix [ 2 ] |
Commented by: @asfernandes Sean, NaN == Not a Number (floating point term). |
Commented by: Philip Williams (unordained) a) this report was for max(), not sum() |
Commented by: @asfernandes The report is valid, see my comment. Depending on the order, NaNs are considered as MAX or not. |
Commented by: Smirnoff Serg (wildsery) I realized that Firebird knows nothing about NaN, and try process it like common float, that's why such artefacts appears. |
Commented by: Paul Faid (pfaid) Further to this report, when I'm using the Firebird embedded server, any sql which tries to interpret the NAN values causes an exception in my Delphi application: EInvalidOp: 'Invalid floating point operation'. The following SQL statements cause an exception if there are any NAN's in CapacityRemaining: I get around this problem by pulling all the values back into my Delphi app and processing them as Delphi Singles (only when using the embedded server) Regards |
Submitted by: Paul Faid (pfaid)
Attachments:
maxnantest.fbk
I have a float column which contains some NANs as well as some valid numbers. When I use MAX(column) sometimes I get NAN and sometimes I get the value I wanted.
After playing around the only difference I can see is what value is in the first record, NAN or a valid number.
If the column value in the first record is a valid number , max(column) behaves as I expect and returns the the highest value in the column that is not NAN
If the column value in the first record is NAN, max(column) returns NAN, irrespective of what else is in the column.
I'll try and attach a db backup which helps illustrate the problem.
The sql I'm using is 'SELECT Max(CapacityRemaining) FROM Datalog WHERE RpsId = 270.
The result = NAN, but if you edit the first record for rpsid:270 and change the NAN to a valid number the query outcome is different.
I've left a selection of other values in the datalog table and by deleting rows you can get NAN's to the first row for any given rpsid.
The text was updated successfully, but these errors were encountered: