update.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 Update(Check):
  13. def initialize(self) -> Testdrive:
  14. return Testdrive(
  15. dedent(
  16. """
  17. > CREATE TABLE update_table (f1 STRING, f2 BIGINT);
  18. > INSERT INTO update_table SELECT 'T1', generate_series FROM generate_series(1,10000);
  19. """
  20. )
  21. )
  22. def manipulate(self) -> list[Testdrive]:
  23. return [
  24. Testdrive(dedent(s))
  25. for s in [
  26. """
  27. > UPDATE update_table SET f2 = f2 * 1000;
  28. """,
  29. """
  30. > UPDATE update_table SET f1 = 'T2', f2 = f2 * 1000;
  31. """,
  32. ]
  33. ]
  34. def validate(self) -> Testdrive:
  35. return Testdrive(
  36. dedent(
  37. """
  38. > SELECT MIN(f1), MAX(f1), MIN(f2), MAX(f2), COUNT(*), COUNT(DISTINCT f2) FROM update_table;
  39. T2 T2 1000000 10000000000 10000 10000
  40. """
  41. )
  42. )