constant_plan.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 ConstantPlan(Check):
  13. def initialize(self) -> Testdrive:
  14. return Testdrive(
  15. dedent(
  16. """
  17. > CREATE TABLE constant_plan1 (f1 INT);
  18. """
  19. )
  20. )
  21. def manipulate(self) -> list[Testdrive]:
  22. return [
  23. Testdrive(dedent(s))
  24. for s in [
  25. """
  26. > CREATE MATERIALIZED VIEW constant_plan_view1 AS SELECT * FROM constant_plan1 WHERE FALSE
  27. """,
  28. """
  29. > CREATE MATERIALIZED VIEW constant_plan_view2 AS (VALUES (1), (2), (3))
  30. """,
  31. ]
  32. ]
  33. def validate(self) -> Testdrive:
  34. return Testdrive(
  35. dedent(
  36. """
  37. > SELECT * FROM constant_plan_view1;
  38. > SELECT * FROM constant_plan_view2;
  39. 1
  40. 2
  41. 3
  42. """
  43. )
  44. )