alterMaterializedViewClustering

Alters the clustering configuration of a materialized view in Snowflake, including setting cluster keys, dropping clustering keys, and controlling automatic reclustering. Materialized views require Snowflake Enterprise Edition or higher.

Note: This change type does not support automatic rollback or database inspection features (snapshot, diff, diff-changelog, and generate-changelog commands).

Available attributes

Attribute

Type

Description

Required

catalogName

String

Name of the catalog (database) containing the materialized view

No

schemaName

String

Name of the schema containing the materialized view

No

viewName

String

Name of the materialized view to alter

Yes

clusterBy

String

Column expression(s) to cluster by*

No

dropClusteringKey

Boolean

Drop the clustering key*

No

suspendRecluster

Boolean

Suspend automatic reclustering*

No

resumeRecluster

Boolean

Resume automatic reclustering*

No

* Exactly one operation must be specified

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:pro-snowflake="http://www.liquibase.org/xml/ns/pro-snowflake"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
        http://www.liquibase.org/xml/ns/pro-snowflake
        http://www.liquibase.org/xml/ns/pro-snowflake/liquibase-pro-snowflake-latest.xsd">
  <!-- Set single-column clustering -->
  <changeSet id="mv-cluster-single" author="examples">
    <pro-snowflake:alterMaterializedViewClustering
                viewName="MV_SALES_DATA"
                clusterBy="CUSTOMER_ID"/>
  </changeSet>
  <!-- Set multi-column clustering -->
  <changeSet id="mv-cluster-multi" author="examples">
    <pro-snowflake:alterMaterializedViewClustering
                viewName="MV_SALES_DATA"
                clusterBy="CUSTOMER_ID, REGION"/>
  </changeSet>
  <!-- Suspend automatic reclustering -->
  <changeSet id="mv-suspend-recluster" author="examples">
    <pro-snowflake:alterMaterializedViewClustering
                viewName="MV_SALES_DATA"
                suspendRecluster="true"/>
  </changeSet>
  <!-- Resume automatic reclustering -->
  <changeSet id="mv-resume-recluster" author="examples">
    <pro-snowflake:alterMaterializedViewClustering
                viewName="MV_SALES_DATA"
                resumeRecluster="true"/>
  </changeSet>
  <!-- Drop clustering key -->
  <changeSet id="mv-drop-clustering" author="examples">
    <pro-snowflake:alterMaterializedViewClustering
                viewName="MV_SALES_DATA"
                dropClusteringKey="true"/>
  </changeSet>
</databaseChangeLog>