select_index_span_ranges.slt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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/select_index_span_ranges
  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. simple conn=mz_system,user=mz_system
  21. ALTER SYSTEM SET unsafe_enable_table_keys = true
  22. ----
  23. COMPLETE 0
  24. # This test verifies that we correctly perform an index join when the KV
  25. # batches span ranges. This is testing that SQL disables batch limits for index
  26. # join; otherwise it can get out of order results from KV that it can't handle.
  27. kv-batch-size 10
  28. statement ok
  29. CREATE TABLE t (
  30. a INT PRIMARY KEY,
  31. b INT,
  32. c INT,
  33. d INT,
  34. FAMILY (a),
  35. FAMILY (b),
  36. FAMILY (c),
  37. FAMILY (d),
  38. INDEX c (c)
  39. )
  40. statement ok
  41. INSERT INTO t VALUES
  42. (1, 0, 99, 0),
  43. (2, 0, 80, 0),
  44. (3, 0, 90, 0),
  45. (4, 0, 10, 0),
  46. (5, 0, 20, 0),
  47. (6, 0, 85, 0),
  48. (7, 0, 91, 0),
  49. (8, 0, 12, 0),
  50. (9, 0, 91, 0),
  51. (10, 0, 11, 0),
  52. (11, 0, 12, 0),
  53. (12, 0, 88, 0),
  54. (13, 0, 13, 0)
  55. # Split the table across multiple ranges.
  56. statement ok
  57. ALTER TABLE t SPLIT AT VALUES (2)
  58. statement ok
  59. ALTER TABLE t SPLIT AT VALUES (3)
  60. statement ok
  61. ALTER TABLE t SPLIT AT VALUES (5)
  62. statement ok
  63. ALTER TABLE t SPLIT AT VALUES (8)
  64. statement ok
  65. ALTER INDEX t@c SPLIT AT VALUES (90)
  66. statement ok
  67. ALTER INDEX c SPLIT AT VALUES (10)
  68. query IIII partialsort(3)
  69. SELECT * FROM t@c WHERE (c >= 80) ORDER BY c
  70. ----
  71. 2 0 80 0
  72. 6 0 85 0
  73. 12 0 88 0
  74. 3 0 90 0
  75. 7 0 91 0
  76. 9 0 91 0
  77. 1 0 99 0