useWarehouse

Sets the active warehouse for the current Snowflake session. This allows you to control which warehouse executes subsequent operations within a changeset.

Note: This change type does not support automatic rollback. Session state is transient.

Available attributes

Attribute

Type

Description

Required

warehouseName

String

Name of the warehouse to use for this session

Yes

<?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">
  <!-- Create warehouse - session switches to NEW_WH -->
  <changeSet id="create-warehouse" author="examples">
    <pro-snowflake:createWarehouse warehouseName="NEW_WH" ifNotExists="true"/>
  </changeSet>
  <!-- Restore session to standard warehouse -->
  <changeSet id="restore-context" author="examples">
    <pro-snowflake:useWarehouse warehouseName="STANDARD_WH"/>
  </changeSet>
</databaseChangeLog>

Important considerations

- Session state only affects the current Liquibase execution

- Each changeset starts with the session warehouse context from the previous changeset

- Changes are not persistent across Liquibase runs

- Not captured in database snapshots (diff/generate-changelog)

- Use useWarehouse instead of raw <sql>USE WAREHOUSE ...</sql> tags for governance