ct_stream_table_join.slt 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. mode cockroach
  10. statement ok
  11. CREATE TABLE big (key INT)
  12. statement ok
  13. CREATE TABLE small (key INT, val STRING)
  14. statement ok
  15. INSERT INTO small VALUES (1, 'v0')
  16. statement ok
  17. CREATE CONTINUAL TASK stj ON INPUT big AS (
  18. INSERT INTO stj SELECT b.key AS k, s.val AS v FROM big b JOIN small s ON b.key = s.key;
  19. )
  20. # Can rename columns via AS when we don't specify them explictly in the CT
  21. query TTTT
  22. SHOW COLUMNS FROM stj;
  23. ----
  24. k true integer (empty)
  25. v true text (empty)
  26. statement ok
  27. INSERT INTO big VALUES (1)
  28. query IT
  29. SELECT * FROM stj
  30. ----
  31. 1 v0
  32. statement ok
  33. UPDATE small SET val = 'v1'
  34. statement ok
  35. INSERT INTO big VALUES (1)
  36. query IT
  37. SELECT * FROM stj
  38. ----
  39. 1 v0
  40. 1 v1