<@U0A71G31CDV> to create a materialized-view in St...
# questions-and-troubleshooting
s
@Rocky to create a materialized-view in StarRocks and have CI + guardrails + test the MV is not being broken by migrations, what tool is recommended which is fully integrated with Starrocks?
r
Short answer: StarRocks has no single officially recommended all-in-one tool that does MV authoring + CI + guardrails + migration regression-testing. The docs describe two officially maintained, StarRocks-integrated options, which you'd combine with your own CI assertions: 1.
dbt-starrocks
(StarRocks GitHub repo, marked experimental in the docs) • Supports "Materialized View materialization" and incremental materialization (3.1+), plus data tests, unit tests,
store_failures
, and source freshness — i.e. models + tests + CI in one workflow. • Caveat: docs flag it as experimental, and I don't see documented specifics on how it versions/alters existing async MVs across migrations (it likely recreates), so verify on a scratch cluster before relying on it for MV-preserving migrations. 2. StarRocks SQLAlchemy dialect + Alembic (
contrib/starrocks-python-client
in the StarRocks repo) • The docs describe this explicitly for _schema management and migration_: declarative models for tables, views and materialized views,
alembic revision --autogenerate
diffing real StarRocks schema vs. your models, version-controlled migration files,
alembic upgrade head
. • Coverage for MVs: create/drop/alter, "limited to mutable clauses such as refresh strategies and properties". Some MV/DDL changes are not reversible and autogenerate will warn or raise — support that with drop+recreate. • Important limitation stated in the docs: StarRocks DDL is not transactional across statements, so a failed migration needs manual remediation. That matters for the "guardrails" part. Guardrails you should build yourself (StarRocks-native, no extra tool): • Before/after each migration, assert
SELECT TABLE_NAME, IS_ACTIVE, INACTIVE_REASON, QUERY_REWRITE_STATUS FROM information_schema.materialized_views
— any MV flipping to
IS_ACTIVE = false
should fail CI. Note schema changes on referenced columns, table rename/swap, and view definition changes all set dependent MVs inactive. • Check
sys.object_dependencies
(v3.2+) to know which MVs a migration will touch, and diff
SHOW CREATE MATERIALIZED VIEW
before/after. • Optionally run
REFRESH MATERIALIZED VIEW ... WITH SYNC MODE
in CI to prove the MV is still refreshable, and
ALTER MATERIALIZED VIEW <mv> ACTIVE
as remediation. One thing to be clear about: I can't verify from the docs that either tool has built-in "MV not broken by migration" assertions — that capability doesn't appear to exist as a packaged feature, so the regression check above is your own CI step. If you want a definitive recommendation for your stack, the dbt adapter repo (github.com/StarRocks/dbt-starrocks) and the starrocks-python-client docs in the StarRocks GitHub repo are the places to confirm current MV behaviour, and the community Slack is a good place to ask which teams use in production. References • using_starrocks/async_mv/feature-support-asynchronous-materialized-views.md • knowledge/known_issues/materialized_view.md (StarRocks knowledge base) • using_starrocks/async_mv/use_cases/data_modeling_with_materialized_views.md • administration/management/monitoring/metrics-materialized_view.md • administration/configuration/FE_parameters/user_query_loading.md • integrations/starrocks_sqlalchemy.md