-
Notifications
You must be signed in to change notification settings - Fork 498
storage/adapter: Opt-in migration of sources to the new table model #30168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
da94ed3
99ebcdd
e6f5f77
4d1aff4
a94504e
95b8a82
7439daa
18a2137
876ba94
000e6d6
30421e6
04f89b6
5da93de
1bc0757
a5dbaf2
2df472c
ce9b45a
50dc1a1
c22a99f
81f3626
4ad14bf
721b09f
d4aa1bd
a6cef8d
56c9cba
42c6af0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Copyright Materialize, Inc. and contributors. All rights reserved. | ||
| # | ||
| # Use of this software is governed by the Business Source License | ||
| # included in the LICENSE file at the root of this repository. | ||
| # | ||
| # As of the Change Date specified in that file, in accordance with | ||
| # the Business Source License, use of this software will be governed | ||
| # by the Apache License, Version 2.0. | ||
|
|
||
| """Utilities for testing the source table migration""" | ||
| from materialize.mz_version import MzVersion | ||
| from materialize.mzcompose.composition import Composition | ||
|
|
||
|
|
||
| def verify_sources_after_source_table_migration( | ||
| c: Composition, file: str, fail: bool = False | ||
| ) -> None: | ||
| source_names_rows = c.sql_query( | ||
| "SELECT sm.name || '.' || src.name FROM mz_sources src INNER JOIN mz_schemas sm ON src.schema_id = sm.id WHERE src.id LIKE 'u%';" | ||
| ) | ||
| source_names = [row[0] for row in source_names_rows] | ||
|
|
||
| print(f"Sources created in {file} are: {source_names}") | ||
|
|
||
| c.sql("SET statement_timeout = '20s'") | ||
|
|
||
| for source_name in source_names: | ||
| _verify_source(c, file, source_name, fail=fail) | ||
|
|
||
|
|
||
| def _verify_source( | ||
| c: Composition, file: str, source_name: str, fail: bool = False | ||
| ) -> None: | ||
| try: | ||
| print(f"Checking source: {source_name}") | ||
|
|
||
| # must not crash | ||
| statement = f"SELECT count(*) FROM {source_name};" | ||
| print(statement) | ||
| c.sql_query(statement) | ||
|
|
||
| statement = f"SHOW CREATE SOURCE {source_name};" | ||
| print(statement) | ||
| result = c.sql_query(statement) | ||
| sql = result[0][1] | ||
| assert "FOR TABLE" not in sql, f"FOR TABLE found in: {sql}" | ||
| assert "FOR ALL TABLES" not in sql, f"FOR ALL TABLES found in: {sql}" | ||
|
|
||
| if not source_name.endswith("_progress"): | ||
| assert "CREATE SUBSOURCE" not in sql, f"CREATE SUBSOURCE found in: {sql}" | ||
|
|
||
| print("OK.") | ||
| except Exception as e: | ||
| print(f"source-table-migration issue in {file}: {str(e)}") | ||
|
|
||
| if fail: | ||
| raise e | ||
|
|
||
|
|
||
| def check_source_table_migration_test_sensible() -> None: | ||
| assert MzVersion.parse_cargo() < MzVersion.parse_mz( | ||
| "v0.130.0" | ||
| ), "migration test probably no longer needed" | ||
|
|
||
|
|
||
| def get_old_image_for_source_table_migration_test() -> str: | ||
| return "materialize/materialized:v0.122.0" | ||
|
Comment on lines
+60
to
+67
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @def- Any chance that you know what the significance of these two versions are?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably just supposed to be an old version to upgrade from, I don't think it actually matters. |
||
|
|
||
|
|
||
| def get_new_image_for_source_table_migration_test() -> str | None: | ||
| return None | ||
Uh oh!
There was an error while loading. Please reload this page.