Before writing a CREATE MATERIALIZED VIEW statement:
- Read
references/parameters.mdto review all available parameters and their defaults. - For each parameter, decide whether the user's request implies a non-default value.
- Include only the parameters that differ from the default or that the user explicitly requested — do not bloat the DDL with unnecessary clauses.
- Never use
CREATE OR REPLACE— always useCREATE MATERIALIZED VIEW IF NOT EXISTS. - Materialized views require Snowflake Enterprise Edition or higher; flag this requirement to the user if the edition is unknown.
- The SELECT statement used to define the materialized view must NOT include HAVING, ORDER BY clauses, or references to stream objects.
- Add CLUSTER BY only for large datasets where the clustering key matches the most common filter patterns — always include an explicit column list when using CLUSTER BY.
- Use SECURE only when the user needs to hide the view definition from non-privileged users.
- Use INTERACTIVE only when the materialized view is based on a single interactive table and low-latency query performance is required.
- Apply MASKING POLICY, ROW ACCESS POLICY, AGGREGATION POLICY, or TAG clauses only when the user explicitly requests governance controls.