ct_audit_log.slt 931 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 mv_input (key INT)
  12. statement ok
  13. INSERT INTO mv_input VALUES (1);
  14. statement ok
  15. CREATE MATERIALIZED VIEW anomalies AS SELECT sum(key)::INT FROM mv_input;
  16. query I
  17. SELECT * FROM anomalies
  18. ----
  19. 1
  20. statement ok
  21. CREATE CONTINUAL TASK audit_log ON INPUT anomalies AS (
  22. INSERT INTO audit_log SELECT * FROM anomalies WHERE sum IS NOT NULL;
  23. )
  24. query I
  25. SELECT * FROM audit_log
  26. ----
  27. 1
  28. statement ok
  29. INSERT INTO mv_input VALUES (2), (3)
  30. query I
  31. SELECT * FROM anomalies
  32. ----
  33. 6
  34. query I
  35. SELECT * FROM audit_log
  36. ----
  37. 1
  38. 6