1_numbers_folding.slt 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. # use mode cockroach because it "respects the scale of a Decimal type and the precision of a floating point number"
  10. # even though mode standard would allow easier file comparisons with the other computation mode
  11. mode cockroach
  12. # -------------------------------
  13. # very small numbers
  14. # -------------------------------
  15. statement ok
  16. CREATE OR REPLACE VIEW v_using_constant_folding (real1, double1, numeric1) AS
  17. SELECT
  18. 1e-39::real, 1e-39::double, 1e-39::numeric;
  19. query RRR
  20. SELECT * FROM v_using_constant_folding
  21. UNION ALL
  22. SELECT SUM(real1), SUM(double1), SUM(numeric1)
  23. FROM v_using_constant_folding;
  24. ----
  25. 0.000000000000000000000000000000000000001 0.000000000000000000000000000000000000001 0.000000000000000000000000000000000000001
  26. 0.000000000000000000000000000000000000001 0.000000000000000000000000000000000000001 0.000000000000000000000000000000000000001
  27. query T multiline
  28. EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR SELECT * FROM v_using_constant_folding;
  29. ----
  30. Explained Query (fast path):
  31. Constant
  32. - (0.000000000000000000000000000000000000001, 0.000000000000000000000000000000000000001, 0.000000000000000000000000000000000000001)
  33. Target cluster: quickstart
  34. EOF
  35. # -------------------------------
  36. # very big numbers
  37. # -------------------------------
  38. statement ok
  39. CREATE OR REPLACE VIEW v_using_constant_folding (real1, double1, numeric1) AS
  40. SELECT
  41. 1e38::real, 1e38::double, 1e38::numeric;
  42. query RRR
  43. SELECT * FROM v_using_constant_folding
  44. UNION ALL
  45. SELECT SUM(real1), SUM(double1), SUM(numeric1)
  46. FROM v_using_constant_folding;
  47. ----
  48. 100000000000000000000000000000000000000 100000000000000000000000000000000000000 100000000000000000000000000000000000000
  49. 100000000000000000000000000000000000000 100000000000000000000000000000000000000 100000000000000000000000000000000000000
  50. query T multiline
  51. EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR SELECT * FROM v_using_constant_folding;
  52. ----
  53. Explained Query (fast path):
  54. Constant
  55. - (100000000000000000000000000000000000000, 100000000000000000000000000000000000000, 100000000000000000000000000000000000000)
  56. Target cluster: quickstart
  57. EOF