transactions-timedomain-nonmaterialized.td 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. $ set-arg-default single-replica-cluster=quickstart
  10. # Test behavior of timedomains with non-materialized sources.
  11. $ kafka-create-topic topic=static
  12. $ kafka-ingest topic=static format=bytes
  13. 1
  14. 2
  15. 4
  16. > CREATE CONNECTION kafka_conn
  17. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  18. > CREATE SOURCE indexed
  19. IN CLUSTER ${arg.single-replica-cluster}
  20. FROM KAFKA CONNECTION kafka_conn
  21. (TOPIC 'testdrive-static-${testdrive.seed}')
  22. > CREATE TABLE indexed_tbl (c) FROM SOURCE indexed (REFERENCE "testdrive-static-${testdrive.seed}")
  23. FORMAT TEXT
  24. > CREATE DEFAULT INDEX ON indexed_tbl
  25. > CREATE SOURCE unindexed
  26. IN CLUSTER ${arg.single-replica-cluster}
  27. FROM KAFKA CONNECTION kafka_conn
  28. (TOPIC 'testdrive-static-${testdrive.seed}')
  29. > CREATE TABLE unindexed_tbl (c) FROM SOURCE unindexed (REFERENCE "testdrive-static-${testdrive.seed}")
  30. FORMAT TEXT
  31. > CREATE VIEW v_unindexed AS SELECT count(*) FROM unindexed_tbl
  32. # A SELECT from the materialized source should succeed outside a transaction.
  33. > SELECT c FROM indexed_tbl ORDER BY c
  34. 1
  35. 2
  36. 4
  37. > SELECT c FROM unindexed_tbl
  38. 1
  39. 2
  40. 4
  41. > SELECT * FROM v_unindexed
  42. 3
  43. > BEGIN
  44. # A SELECT from the materialized source in a transaction should succeed
  45. # even though a non-materialized source is in the same time domain.
  46. > SELECT c FROM indexed_tbl ORDER BY c
  47. 1
  48. 2
  49. 4
  50. > SELECT c FROM unindexed_tbl
  51. 1
  52. 2
  53. 4
  54. > COMMIT
  55. # The unindexed view should be the same.
  56. > BEGIN
  57. > SELECT c FROM indexed_tbl ORDER BY c
  58. 1
  59. 2
  60. 4
  61. > SELECT * FROM v_unindexed
  62. 3
  63. > COMMIT
  64. # Ensure that other optionally indexed things (views) are correctly
  65. # included in the timedomain.
  66. > CREATE VIEW v AS SELECT COUNT(*) FROM indexed_tbl
  67. # Wait until there are results.
  68. > SELECT * FROM v
  69. 3
  70. > BEGIN
  71. > SELECT c FROM indexed_tbl ORDER BY c
  72. 1
  73. 2
  74. 4
  75. > SELECT * FROM v
  76. 3
  77. > COMMIT
  78. # Make v indexed to ensure it works too.
  79. > CREATE DEFAULT INDEX ON v;
  80. # Wait until there are results.
  81. > SELECT * FROM v
  82. 3
  83. > BEGIN
  84. > SELECT c FROM indexed_tbl ORDER BY c
  85. 1
  86. 2
  87. 4
  88. > SELECT * FROM v
  89. 3
  90. > COMMIT
  91. # Regression for database-issues#2647
  92. # Ensure that views referencing other schemas are transitively included. Here,
  93. # pg_catalog is generally a view over mz_catalog.
  94. > BEGIN
  95. > SELECT c.oid FROM pg_catalog.pg_class c LIMIT 0;
  96. > SELECT pg_catalog.format_type(a.atttypid, a.atttypmod) FROM pg_catalog.pg_attribute a LIMIT 0;
  97. > COMMIT
  98. # Regression for database-issues#2727
  99. # Ensure that non-materialized, transitive views are not included. Here,
  100. # unindexed should not be included in the timedomain.
  101. > CREATE MATERIALIZED VIEW v_materialized AS SELECT count(*) FROM unindexed
  102. # Wait for the view to be updated, since we can't retry in the transaction if
  103. # it returns a 0 timestamp error.
  104. > SELECT * FROM v_materialized
  105. 3
  106. > BEGIN
  107. > SELECT * FROM v_materialized
  108. 3
  109. > COMMIT