harrystech / arthur-redshift-etl

ELT Code for your Data Warehouse
MIT License
26 stars 11 forks source link

Add flag to not backup on promoting to staging #743

Closed ynaim94 closed 2 years ago

ynaim94 commented 2 years ago

Description

Adding flag to not backup loaded data when promoting staging data. This allow us to temporarily save disk space.

QA

Creating table in staging

arthur.py upgrade --with-staging mock_arthur_schema

Promoting from staging

arthur.py promote_schemas --from-position staging mock_arthur_schema 
...
2022-06-22 16:45:13 - INFO - Creating backup of schema(s) 'mock_arthur_schema'
2022-06-22 16:45:13 - INFO - Revoking access from readers and writers to schema 'mock_arthur_schema' before backup
2022-06-22 16:45:15 - INFO - Renaming schema 'mock_arthur_schema' to backup 'etl_backup$mock_arthur_schema'
2022-06-22 16:45:16 - INFO - Promoting 1 schema(s) from staging position: 'mock_arthur_schema'
2022-06-22 16:45:16 - INFO - Renaming schema 'mock_arthur_schema' from 'etl_staging$mock_arthur_schema'
...
-- Table was promoted
SELECT *
FROM mock_arthur_schema.table;
a_column
constant
-- Table was backed up 
SELECT *
FROM etl_backup$mock_arthur_schema.table;
a_column
constant

Recreating table in staging

arthur.py upgrade --with-staging mock_arthur_schema
SELECT *
FROM etl_staging$mock_arthur_schema.table;
a_column
constant

Promoting from staging with no backup

arthur.py promote_schemas --from-position staging mock_arthur_schema --no-backup
...
2022-06-22 16:45:40 - INFO - Promoting 1 schema(s) from staging position: 'mock_arthur_schema'
2022-06-22 16:45:40 - INFO - Renaming schema 'mock_arthur_schema' from 'etl_staging$mock_arthur_schema'
...
-- Table was promoted
SELECT *
FROM mock_arthur_schema.table;
a_column
constant
-- This should return table not found
SELECT *
FROM etl_backup$mock_arthur_schema.table;

Promoting from backup

arthur.py promote_schemas --from-position backup mock_arthur_schema            
...
2022-06-22 16:46:07 - INFO - Promoting 1 schema(s) from backup position: 'mock_arthur_schema'
2022-06-22 16:46:07 - INFO - Renaming schema 'mock_arthur_schema' from 'etl_backup$mock_arthur_schema'
...
-- Table was promoted
SELECT *
FROM mock_arthur_schema.table;
a_column
constant

Recreating table in staging

arthur.py upgrade --with-staging mock_arthur_schema
SELECT *
FROM etl_staging$mock_arthur_schema.table;
a_column
constant

Recreating table in backup

arthur.py promote_schemas --from-position staging mock_arthur_schema            
SELECT *
FROM etl_backup$mock_arthur_schema.table;
a_column
constant

Promoting from backup with no-backup flag (The flag has no effect here)

arthur.py promote_schemas --from-position backup mock_arthur_schema --no-backup
...
2022-06-22 16:46:36 - INFO - Promoting 1 schema(s) from backup position: 'mock_arthur_schema'
2022-06-22 16:46:36 - INFO - Renaming schema 'mock_arthur_schema' from 'etl_backup$mock_arthur_schema'
...
SELECT *
FROM mock_arthur_schema.table;
a_column
constant
-- This should return table not found
SELECT *
FROM etl_backup$mock_arthur_schema.table;
a_column
constant
soumyadsanyal-harrys commented 2 years ago

Initial questions on the QA:

Promoting from backup

arthur.py promote_schemas --from-position backup mock_arthur_schema            
...
2022-06-22 16:46:07 - INFO - Promoting 1 schema(s) from backup position: 'mock_arthur_schema'
2022-06-22 16:46:07 - INFO - Renaming schema 'mock_arthur_schema' from 'etl_backup$mock_arthur_schema'
...
-- Table was promoted
SELECT *
FROM mock_arthur_schema.table;

a_column constant

Did this succeed because of the prior arthur.py promote_schemas --from-position staging mock_arthur_schema command?

Recreating table in backup

arthur.py promote_schemas --from-position staging mock_arthur_schema            
SELECT *
FROM etl_backup$mock_arthur_schema.table;

a_column constant

Given that you previously ran arthur.py promote_schemas --from-position staging mock_arthur_schema --no-backup, did you need to also run arthur.py upgrade --with-staging mock_arthur_schema before running this?