Snowflake-Labs / schemachange

A Database Change Management tool for Snowflake
Apache License 2.0
481 stars 219 forks source link

3.5.3 not using default role and warehouse #194

Closed marcusintrohive closed 10 months ago

marcusintrohive commented 10 months ago

With the recent package upgrade we are no longer switching back to the default role to apply the migration in the METADATA database.

Examples:

Migration that uses the SECURITYADMIN role to create a custom role

-- Create Airflow role

-- Use SECURITYADMIN role
USE ROLE SECURITYADMIN;

CREATE ROLE IF NOT EXISTS AIRFLOW;

Fails with the following error

snowflake.connector.errors.ProgrammingError: 002003 (02000): SQL compilation error:
Database 'METADATA' does not exist or not authorize

However if I switch back to the SYSADMIN role at the end of the migration it will not fail and work as expected

-- Create Airflow role

-- Use SECURITYADMIN role
USE ROLE SECURITYADMIN;

CREATE ROLE IF NOT EXISTS AIRFLOW;

USE ROLE SYSADMIN;

From our CI pipeline, we are seeing it is not using the default warehouse being passed in as well when running the same migration. Not sure if this is something that recently changed with the snowflake-connector-

snowflake.connector.errors.ProgrammingError: 000606 (57P03): No active warehouse selected in the current session.  Select an active warehouse with the 'use warehouse' command.
sfc-gh-jhansen commented 10 months ago

These changes were deployed in v3.6.0, see PR #195