float_sum.td 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. #
  10. # Test the implementation of SUM over floats
  11. #
  12. > CREATE TABLE "nan" (f1 float);
  13. > INSERT INTO "nan" VALUES ('NaN');
  14. > SELECT SUM(f1) FROM "nan";
  15. NaN
  16. > CREATE TABLE "neg_infinity" (f1 float);
  17. > INSERT INTO "neg_infinity" VALUES ('-infinity');
  18. > SELECT SUM(f1) FROM "neg_infinity";
  19. -inf
  20. > CREATE TABLE a (f1 float);
  21. > INSERT INTO a VALUES ('infinity');
  22. > SELECT SUM(f1) FROM a;
  23. inf
  24. > INSERT INTO a VALUES (5.12);
  25. > SELECT SUM(f1) FROM a;
  26. inf
  27. > INSERT INTO a VALUES ('-infinity');
  28. > SELECT SUM(f1) FROM a;
  29. NaN
  30. > DELETE FROM a WHERE f1 <> 5.12;
  31. # TODO(petrosagg): this is a correctness issue that is a consequence of mapping
  32. # float values onto a i128 domain to do the aggregation
  33. > SELECT SUM(f1) FROM a;
  34. 5.119999945163727
  35. > DELETE FROM a;
  36. > SELECT SUM(f1) FROM a;
  37. <null>
  38. > INSERT INTO a VALUES (NULL);
  39. > SELECT SUM(f1) FROM a;
  40. <null>