Creates a table on the Mz instance. 50% of the tables have a default index.
| 57 | |
| 58 | |
| 59 | class CreateTable(Action): |
| 60 | """Creates a table on the Mz instance. 50% of the tables have a default index.""" |
| 61 | |
| 62 | @classmethod |
| 63 | def requires(cls) -> set[type[Capability]]: |
| 64 | return {BalancerdIsRunning, MzIsRunning} |
| 65 | |
| 66 | def __init__(self, table: TableExists, capabilities: Capabilities) -> None: |
| 67 | assert ( |
| 68 | table is not None |
| 69 | ), "CreateTable Action can not be referenced directly, it is produced by CreateTableParameterized factory" |
| 70 | self.table = table |
| 71 | super().__init__(capabilities) |
| 72 | |
| 73 | def run(self, c: Composition, state: State) -> None: |
| 74 | index = ( |
| 75 | f"> CREATE DEFAULT INDEX ON {self.table.name}" |
| 76 | if self.table.has_index |
| 77 | else "" |
| 78 | ) |
| 79 | c.testdrive( |
| 80 | dedent(f""" |
| 81 | > CREATE TABLE {self.table.name} (f1 INTEGER); |
| 82 | {index} |
| 83 | > INSERT INTO {self.table.name} VALUES ({self.table.watermarks.max}); |
| 84 | """), |
| 85 | mz_service=state.mz_service, |
| 86 | ) |
| 87 | |
| 88 | def provides(self) -> list[Capability]: |
| 89 | return [self.table] |
| 90 | |
| 91 | |
| 92 | class ValidateTable(Action): |
no outgoing calls
no test coverage detected