Alter Standard Table - Data Metrics

Modifies data metric configurations including schedule and metric functions.

Known limitations:

  • This change type does not support automatic rollback.

  • Snowflake snapshots created with Liquibase Secure 5.1 are incompatible with earlier versions due to enhanced object type detection for TABLES and VIEWS. Regenerate all snapshots with 5.1 after upgrading to avoid false differences in diff and diff-changelog operations.

Available attributes

Attribute

Type

Description

Required

catalogName

String

Name of the catalog (database) containing the table

No

schemaName

String

Name of the schema containing the table

No

tableName

String

Name of the table to alter

Yes

ifExists

Boolean

Only execute if the table exists

No

Data metric schedule

Controls when data metrics are calculated.

alterDataMetricSchedule nested attributes

Attribute

Type

Description

Required

newSchedule

String

New schedule expression

No*

unsetSchedule

Boolean

If true, unsets the schedule

No*

*Exactly one of newSchedule or unsetSchedule 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 data metric schedule -->
  <changeSet id="set-data-metric-schedule" author="examples">
    <pro-snowflake:alterStandardTable tableName="MONITORED_TABLE">
      <pro-snowflake:alterDataMetricSchedule newSchedule="USING CRON 0 9 * * * UTC"/>
    </pro-snowflake:alterStandardTable>
  </changeSet>
  <!-- Unset data metric schedule -->
  <changeSet id="unset-data-metric-schedule" author="examples">
    <pro-snowflake:alterStandardTable tableName="MONITORED_TABLE">
      <pro-snowflake:alterDataMetricSchedule unsetSchedule="true"/>
    </pro-snowflake:alterStandardTable>
  </changeSet>
</databaseChangeLog>

Data metric functions

Adds, modifies, or drops data metric functions.

alterDataMetricFunction nested attributes

Attribute

Type

Description

Required

metricCatalog

String

Catalog containing the metric function

No

metricSchema

String

Schema containing the metric function

No

metricName

String

Name of the metric function

Yes

on

String

Column(s) the metric applies to

No

action

String

Action to perform: ADD, MODIFY, DROP

Yes

modifyExpression

String

New expression for MODIFY action

No

executeAsRole

String

Role to execute as

No

<?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">
  <!-- Add data metric function -->
  <changeSet id="add-data-metric-function" author="examples">
    <pro-snowflake:alterStandardTable tableName="QUALITY_MONITORED">
      <pro-snowflake:alterDataMetricFunction
                metricSchema="METRICS"
                metricName="CHECK_COMPLETENESS"
                on="EMAIL, PHONE"
                action="ADD"/>
    </pro-snowflake:alterStandardTable>
  </changeSet>
  <!-- Modify data metric function -->
  <changeSet id="modify-data-metric-function" author="examples">
    <pro-snowflake:alterStandardTable tableName="QUALITY_MONITORED">
      <pro-snowflake:alterDataMetricFunction
                metricSchema="METRICS"
                metricName="CHECK_COMPLETENESS"
                on="EMAIL, PHONE, ADDRESS"
                action="MODIFY"
                modifyExpression="COUNT(*) WHERE EMAIL IS NOT NULL AND PHONE IS NOT NULL AND ADDRESS IS NOT NULL"/>
    </pro-snowflake:alterStandardTable>
  </changeSet>
  <!-- Drop data metric function -->
  <changeSet id="drop-data-metric-function" author="examples">
    <pro-snowflake:alterStandardTable tableName="QUALITY_MONITORED">
      <pro-snowflake:alterDataMetricFunction
                metricSchema="METRICS"
                metricName="CHECK_COMPLETENESS"
                action="DROP"/>
    </pro-snowflake:alterStandardTable>
  </changeSet>
</databaseChangeLog>