Add teardown cascade option
Pre-review checklist
- [x] I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
- [x] I've added or updated automated unit tests to verify correctness of my new code.
- [x] I've added or updated integration tests to verify correctness of my new code.
- [x] I've confirmed that my changes are working by executing CLI's commands manually.
- [x] I've confirmed that my changes are up-to-date with the target branch.
- [x] I've described my changes in the release notes.
- [x] I've described my changes in the section below.
Changes description
Adding the --cascade option when running snow app teardown which will be passed to the DROP APPLICATION command. A list of the affected objects will be printed to the user.
Without it, when the application owns account level objects outside of the app such as compute pools/warehouses/databases, snow app teardown will fail with a general error: Could not successfully execute the Snowflake SQL statements. The specific SQL error is shown with --debug.
Interactive mode
In interactive mode, if --cascade/--no-cascade was not explicitly provided, the user will be prompted for an input with the list of objects that will be dropped if approved. The following demo shows the abort (default), no and yes flows:
https://github.com/snowflakedb/snowflake-cli/assets/162226501/91774b98-a069-439e-9cd7-5d7151dd6546
No cascade
Teardown with no explicit --cascade/--no-cascade:
$ snow app teardown
╭─ Error ───────────────────────────────────────────────────────────────────────╮
│ The following application objects are owned application spcs_na_5_gbloom: │
│ (WAREHOUSE) SPCS_NA_5_GBLOOM_WH │
│ │
│ Aborting, re-run teardown again with --cascade or --no-cascade to specify │
│ whether these objects should be dropped along with the application. │
╰───────────────────────────────────────────────────────────────────────────────╯
Teardown with explicit --no-cascade:
snow app teardown --no-cascade
The following objects are owned by application spcs_na_5_gbloom:
(WAREHOUSE) SPCS_NA_5_GBLOOM_WH
Dropping application spcs_na_5_gbloom now.
╭─ Error ───────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ Could not successfully execute the Snowflake SQL statements. │
│ │
│ drop application spcs_na_5_gbloom │
│ │
╰───────────────────────────────────────────────────────────────────────────────╯
Integration & manual tests
The added integration tests fails on CI due to insufficient privileges for the CI role. I verified the tests pass locally with a test user. I committed the test and marked it to be skipped.
I also manually created an app that owns a warehouse and ran the same flows:
-
app teardown -
app teardown --force --no-cascade -
app teardown --cascade