Materialized Views in Redshift
These tests assume that the MVs work correctly, so any errors are due to the CLI commands and aren't MV errors.
This series of commands will show the usage the following matview CLI commands:
matview-create
matview-delete
matview-describe
matview-stats
matview-list
matview-pause-all
matview-resume-all
We will create a timeseries table of fake data called datacoral_test.fake_events
. The timeseries, timeseriesio, and regular table will be based on this table. The timeserieso table will be based on the regular MV.
Create a timeseries table to use in the tests:
Now you have a series of timeseries tables. We need these two tables to make sure that the MVs we create don't pick up the wrong data somehow.
Create different kinds of MVs
Create a timeseriesio MV
Save as timeseriesio_page_loads_mv.sql
.
Run the following CLI command:
Create a timeseries MV
Save as timeseries_registrations_mv.sql
.
Run the following CLI command:
Create regular MV
Save as regular_daily_snapshot_mv.sql
.
Run the following CLI command:
Create timeserieso MV
Initially the mv_company_metrics
table will be identical to the mv_daily_snapshot
table.
Save as timeserieso_company_metrics_mv.sql
.
Run the following CLI command:
Check that the datacoral organize matview-create
commands above did actually work:
Returns mv_page_loads
, mv_registrations
, mv_daily_snapshot
, mv_company_metrics
.
Check that the sort and dist keys were created correctly:
This should return sortkey1=reg_date
, sortkey_num = 1
, and diststyle=reg_date
.
This should return empty sortkey1, sortkey_num, and diststyle fields.
datacoral organize matview-list
Check Returns
datacoral organize matview-describe
Check Returns
datacoral organize matview-describe --dependencies
Check Returns
datacoral organize matview-stats
Check Returns
datacoral organize matview-pause-all
Check This and the resume-all commands will have to be tested around the update time. Or another method must be used.
datacoral organize matview-resume-all
Check datacoral organize matview-delete
Check In Redshift the following commands should return zero results.
Clean up - delete the remaining test tables and drop the schema
In Redshift: