drop_table.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. from textwrap import dedent
  10. from materialize.checks.actions import Testdrive
  11. from materialize.checks.checks import Check
  12. class DropTable(Check):
  13. def initialize(self) -> Testdrive:
  14. return Testdrive(
  15. dedent(
  16. """
  17. > CREATE TABLE drop_table1 (f1 INTEGER);
  18. > INSERT INTO drop_table1 VALUES (1);
  19. > CREATE TABLE drop_table2 (f1 INTEGER);
  20. > INSERT INTO drop_table2 VALUES (1);
  21. """
  22. )
  23. )
  24. def manipulate(self) -> list[Testdrive]:
  25. return [
  26. Testdrive(dedent(s))
  27. for s in [
  28. """
  29. > DROP TABLE drop_table1;
  30. """,
  31. """
  32. > DROP TABLE drop_table2;
  33. """,
  34. ]
  35. ]
  36. def validate(self) -> Testdrive:
  37. return Testdrive(
  38. dedent(
  39. """
  40. ! SELECT * FROM drop_table1;
  41. contains: unknown catalog item
  42. ! SELECT * FROM drop_table2;
  43. contains: unknown catalog item
  44. """
  45. )
  46. )