create-in-v0.38.0-range.td 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. # CREATE views containing ranges
  11. > CREATE MATERIALIZED VIEW int4range_view (a) AS
  12. SELECT column1::int4range FROM
  13. (
  14. VALUES
  15. ('[,1)'),
  16. ('[,1]'),
  17. ('[,)'),
  18. ('[,]'),
  19. ('(,1)'),
  20. ('(,1]'),
  21. ('(,)'),
  22. ('(,]'),
  23. ('[-1,1)'),
  24. ('[-1,1]'),
  25. ('(-1,1)'),
  26. ('(-1,1]'),
  27. ('[0,0)'),
  28. ('[0,0]'),
  29. ('(0,0)'),
  30. ('(0,0]'),
  31. ('[1,)'),
  32. ('[1,]'),
  33. ('(1,)'),
  34. ('(1,]')
  35. );
  36. > SELECT a::text AS t FROM int4range_view ORDER BY a;
  37. empty
  38. empty
  39. empty
  40. (,1)
  41. (,1)
  42. (,2)
  43. (,2)
  44. (,)
  45. (,)
  46. (,)
  47. (,)
  48. [-1,1)
  49. [-1,2)
  50. [0,1)
  51. [0,1)
  52. [0,2)
  53. [1,)
  54. [1,)
  55. [2,)
  56. [2,)
  57. > CREATE MATERIALIZED VIEW int8range_view (a) AS
  58. SELECT column1::int8range FROM
  59. (
  60. VALUES
  61. ('[,1)'),
  62. ('[,1]'),
  63. ('[,)'),
  64. ('[,]'),
  65. ('(,1)'),
  66. ('(,1]'),
  67. ('(,)'),
  68. ('(,]'),
  69. ('[-1,1)'),
  70. ('[-1,1]'),
  71. ('(-1,1)'),
  72. ('(-1,1]'),
  73. ('[0,0)'),
  74. ('[0,0]'),
  75. ('(0,0)'),
  76. ('(0,0]'),
  77. ('[1,)'),
  78. ('[1,]'),
  79. ('(1,)'),
  80. ('(1,]')
  81. );
  82. > SELECT a::text AS t FROM int4range_view ORDER BY a;
  83. empty
  84. empty
  85. empty
  86. (,1)
  87. (,1)
  88. (,2)
  89. (,2)
  90. (,)
  91. (,)
  92. (,)
  93. (,)
  94. [-1,1)
  95. [-1,2)
  96. [0,1)
  97. [0,1)
  98. [0,2)
  99. [1,)
  100. [1,)
  101. [2,)
  102. [2,)
  103. > CREATE MATERIALIZED VIEW daterange_view (a) AS
  104. SELECT column1::daterange FROM
  105. (
  106. VALUES
  107. ('[,)'),
  108. ('[,1970-01-01]'),
  109. ('[,)'),
  110. ('[,]'),
  111. ('(,1970-01-01)'),
  112. ('(,1970-01-01]'),
  113. ('(,)'),
  114. ('(,]'),
  115. ('[1969-12-31,1970-01-01)'),
  116. ('[1969-12-31,1970-01-01]'),
  117. ('(1969-12-31,1970-01-01)'),
  118. ('(1969-12-31,1970-01-01]'),
  119. ('[1970-01-01,)'),
  120. ('[1970-01-01,]'),
  121. ('(1970-01-01,)'),
  122. ('(1970-01-01,]')
  123. );
  124. > SELECT a::text AS t FROM daterange_view ORDER BY a;
  125. empty
  126. (,1970-01-01)
  127. (,1970-01-02)
  128. (,1970-01-02)
  129. (,)
  130. (,)
  131. (,)
  132. (,)
  133. (,)
  134. [1969-12-31,1970-01-01)
  135. [1969-12-31,1970-01-02)
  136. [1970-01-01,1970-01-02)
  137. [1970-01-01,)
  138. [1970-01-01,)
  139. [1970-01-02,)
  140. [1970-01-02,)