zero.slt 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. # Copyright 2015 - 2019 The Cockroach Authors. All rights reserved.
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. #
  11. # This file is derived from the logic test suite in CockroachDB. The
  12. # original file was retrieved on June 10, 2019 from:
  13. #
  14. # https://github.com/cockroachdb/cockroach/blob/d2f7fbf5dd1fc1a099bbad790a2e1f7c60a66cc3/pkg/sql/logictest/testdata/logic_test/zero
  15. #
  16. # The original source code is subject to the terms of the Apache
  17. # 2.0 license, a copy of which can be found in the LICENSE file at the
  18. # root of this repository.
  19. mode cockroach
  20. # This tests zeros and numbers with trailing zeros.
  21. # ints
  22. statement ok
  23. CREATE TABLE i (i int, v int)
  24. statement ok
  25. INSERT INTO i VALUES
  26. (1, 0),
  27. (2, -0),
  28. (3, 0::int),
  29. (4, -0::int),
  30. (5, '0'::int),
  31. (6, '-0'::int)
  32. query II
  33. select * FROM i ORDER BY i
  34. ----
  35. 1 0
  36. 2 0
  37. 3 0
  38. 4 0
  39. 5 0
  40. 6 0
  41. query IIIIII
  42. SELECT 0, -0, 0::int, -0::int, '0'::int, '-0'::int
  43. ----
  44. 0 0 0 0 0 0
  45. # floats
  46. statement ok
  47. CREATE TABLE f (i int, v float)
  48. statement ok
  49. INSERT INTO f VALUES
  50. (1, 0.0),
  51. (2, -0.0),
  52. (3, 0.00::float),
  53. (4, -0.00::float),
  54. (5, (-0.000)::float),
  55. (6, 0::float),
  56. (7, -0::float),
  57. (8, '0.0000'::float),
  58. (9, '-0.0000'::float),
  59. (10, 0),
  60. (11, -0)
  61. query IR
  62. select * FROM f ORDER BY i
  63. ----
  64. 1 0
  65. 2 -0
  66. 3 0
  67. 4 -0
  68. 5 -0
  69. 6 0
  70. 7 -0
  71. 8 0
  72. 9 -0
  73. 10 0
  74. 11 -0
  75. query RRRRRIIRRRR colnames
  76. SELECT 0.0::float as a,
  77. -0.0::float as b,
  78. 0.00::float as c,
  79. -0.00::float as d,
  80. (-0.000)::float as e,
  81. 0 as f,
  82. -0 as g,
  83. 0::float as h,
  84. -0::float as i,
  85. '0.0000'::float as j,
  86. '-0.0000'::float as k
  87. ----
  88. a b c d e f g h i j k
  89. 0 -0 0 -0 -0 0 0 0 -0 0 -0
  90. # decimals
  91. query RRRRRRRRR colnames
  92. SELECT 0.0::decimal as a,
  93. -0.0::decimal as b,
  94. 0.00::decimal as c,
  95. -0.00::decimal as d,
  96. (-0.000)::decimal as e,
  97. 0::decimal as f,
  98. -0::decimal as g,
  99. '0.0000'::decimal as h,
  100. '-0.0000'::decimal as i
  101. ----
  102. a b c d e f g h i
  103. 0.0 0.0 0.00 0.00 0.000 0 0 0.0000 0.0000
  104. statement ok
  105. CREATE TABLE d (i INT, v DECIMAL)
  106. statement ok
  107. INSERT INTO d VALUES
  108. (1, 0.0),
  109. (2, -0.0),
  110. (3, 0.00::decimal),
  111. (4, -0.00::decimal),
  112. (5, (-0.000)::decimal),
  113. (6, 0::decimal),
  114. (7, -0::decimal),
  115. (8, '0.0000'::decimal),
  116. (9, '-0.0000'::decimal),
  117. (10, 0),
  118. (11, -0)
  119. query IR
  120. select * FROM d ORDER BY i
  121. ----
  122. 1 0.0
  123. 2 0.0
  124. 3 0.00
  125. 4 0.00
  126. 5 0.000
  127. 6 0
  128. 7 0
  129. 8 0.0000
  130. 9 0.0000
  131. 10 0
  132. 11 0
  133. statement ok
  134. CREATE TABLE didx (i INT, v DECIMAL, INDEX vidx (v))
  135. statement ok
  136. INSERT INTO didx VALUES
  137. (1, 0.0),
  138. (2, -0.0),
  139. (3, 0.00::decimal),
  140. (4, -0.00::decimal),
  141. (5, (-0.000)::decimal),
  142. (6, 0::decimal),
  143. (7, -0::decimal),
  144. (8, '0.0000'::decimal),
  145. (9, '-0.0000'::decimal),
  146. (10, 0),
  147. (11, -0)
  148. query R
  149. SELECT v FROM didx ORDER BY INDEX didx@vidx
  150. ----
  151. 0.0
  152. 0.0
  153. 0.00
  154. 0.00
  155. 0.000
  156. 0
  157. 0
  158. 0.0000
  159. 0.0000
  160. 0
  161. 0
  162. query RRRR
  163. SELECT - -0.00::decimal, - - -0.00::decimal, - - -0.00, - -0.00
  164. ----
  165. 0.00 0.00 0.00 0.00
  166. # TODO(mjibson):
  167. #
  168. #query RRRR
  169. #SELECT -+-0.010::decimal, 0.020, 0.030::decimal, -0.0400000000000000000000000000
  170. #----
  171. #0.010 0.020 0.030 -0.0400000000000000000000000000
  172. #
  173. #query RR
  174. #SELECT -0.040 + 0, 0.040::decimal + 0
  175. #----
  176. #-0.040 0.040
  177. query R
  178. SELECT * FROM (VALUES (-0.0::DECIMAL), (-0::DECIMAL), (0::DECIMAL), (-0.00::DECIMAL)) ORDER BY 1
  179. ----
  180. 0.0
  181. 0
  182. 0
  183. 0.00