numeric.td 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. > CREATE TABLE numeric_insertions (a numeric(39,2));
  10. > CREATE TABLE numeric_deletions (a numeric(39,2));
  11. > CREATE VIEW numeric_values AS
  12. SELECT a FROM numeric_insertions
  13. EXCEPT (SELECT a FROM numeric_deletions);
  14. > INSERT INTO numeric_insertions VALUES ('0.0001');
  15. > INSERT INTO numeric_insertions VALUES ('0.009');
  16. > SELECT a, a = 0 AS eq_zero FROM numeric_values;
  17. a eq_zero
  18. ------------
  19. 0 true
  20. 0.01 false
  21. # Ensure values are rescaled on insert
  22. > INSERT INTO numeric_insertions VALUES (1.2345);
  23. > SELECT a FROM numeric_values ORDER BY a
  24. a
  25. ----
  26. 0
  27. 0.01
  28. 1.23
  29. # This previously panicked due to a failed conversion from numeric to i128
  30. # statement ok
  31. > CREATE OR REPLACE MATERIALIZED VIEW numeric_cast_ok AS
  32. SELECT 1
  33. WHERE mz_now() > 0::numeric(38,0);
  34. > SELECT * FROM numeric_cast_ok;
  35. 1