transactions-timedomain-nonmaterialized.td 2.9 KB

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