Skip to content

Commit

Permalink
Replaced staging tables to views to test transformation performance
Browse files Browse the repository at this point in the history
  • Loading branch information
smunthik committed Nov 18, 2024
1 parent 344729c commit afe6674
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions shared/bcts_reports_etl/Annual_Developed_Volume_Query.sql
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
DROP TABLE IF EXISTS bcts_staging.DIVISION;
CREATE TABLE bcts_staging.DIVISION AS
DROP VIEW IF EXISTS bcts_staging.DIVISION;
CREATE VIEW bcts_staging.DIVISION AS
SELECT * FROM lrm_replication.DIVISION;

DROP TABLE IF EXISTS bcts_staging.BLOCK_ALLOCATION;
CREATE TABLE bcts_staging.BLOCK_ALLOCATION AS
DROP VIEW IF EXISTS bcts_staging.BLOCK_ALLOCATION;
CREATE VIEW bcts_staging.BLOCK_ALLOCATION AS
SELECT * FROM lrm_replication.BLOCK_ALLOCATION;

DROP TABLE IF EXISTS bcts_staging.MANAGEMENT_UNIT;
CREATE TABLE bcts_staging.MANAGEMENT_UNIT AS
DROP VIEW IF EXISTS bcts_staging.MANAGEMENT_UNIT;
CREATE VIEW bcts_staging.MANAGEMENT_UNIT AS
SELECT * FROM lrm_replication.MANAGEMENT_UNIT;

DROP TABLE IF EXISTS bcts_staging.LICENCE;
CREATE TABLE bcts_staging.LICENCE AS
DROP VIEW IF EXISTS bcts_staging.LICENCE;
CREATE VIEW bcts_staging.LICENCE AS
SELECT * FROM lrm_replication.LICENCE;

DROP TABLE IF EXISTS bcts_staging.BLOCK_ADMIN_ZONE;
CREATE TABLE bcts_staging.BLOCK_ADMIN_ZONE AS
DROP VIEW IF EXISTS bcts_staging.BLOCK_ADMIN_ZONE;
CREATE VIEW bcts_staging.BLOCK_ADMIN_ZONE AS
SELECT * FROM lrm_replication.BLOCK_ADMIN_ZONE;

DROP TABLE IF EXISTS bcts_staging.DIVISION_CODE_LOOKUP;
CREATE TABLE bcts_staging.DIVISION_CODE_LOOKUP AS
DROP VIEW IF EXISTS bcts_staging.DIVISION_CODE_LOOKUP;
CREATE VIEW bcts_staging.DIVISION_CODE_LOOKUP AS
SELECT * FROM lrm_replication.DIVISION_CODE_LOOKUP;

DROP TABLE IF EXISTS bcts_staging.CODE_LOOKUP;
CREATE TABLE bcts_staging.CODE_LOOKUP AS
DROP VIEW IF EXISTS bcts_staging.CODE_LOOKUP;
CREATE VIEW bcts_staging.CODE_LOOKUP AS
SELECT * FROM lrm_replication.CODE_LOOKUP;

DROP TABLE IF EXISTS bcts_staging.TENURE_TYPE;
CREATE TABLE bcts_staging.TENURE_TYPE AS
DROP VIEW IF EXISTS bcts_staging.TENURE_TYPE;
CREATE VIEW bcts_staging.TENURE_TYPE AS
SELECT * FROM lrm_replication.TENURE_TYPE;

DROP TABLE IF EXISTS bcts_staging.CUT_PERMIT;
CREATE TABLE bcts_staging.CUT_PERMIT AS
DROP VIEW IF EXISTS bcts_staging.CUT_PERMIT;
CREATE VIEW bcts_staging.CUT_PERMIT AS
SELECT * FROM lrm_replication.CUT_PERMIT;

DROP TABLE IF EXISTS bcts_staging.MARK;
CREATE TABLE bcts_staging.MARK AS
DROP VIEW IF EXISTS bcts_staging.MARK;
CREATE VIEW bcts_staging.MARK AS
SELECT * FROM lrm_replication.MARK;

DROP TABLE IF EXISTS bcts_staging.DIVISION_CODE_LOOKUP;
CREATE TABLE bcts_staging.DIVISION_CODE_LOOKUP AS
DROP VIEW IF EXISTS bcts_staging.DIVISION_CODE_LOOKUP;
CREATE VIEW bcts_staging.DIVISION_CODE_LOOKUP AS
SELECT * FROM lrm_replication.DIVISION_CODE_LOOKUP;

DROP TABLE IF EXISTS bcts_staging.CUT_BLOCK;
CREATE TABLE bcts_staging.CUT_BLOCK AS
DROP VIEW IF EXISTS bcts_staging.CUT_BLOCK;
CREATE VIEW bcts_staging.CUT_BLOCK AS
SELECT * FROM lrm_replication.CUT_BLOCK;

DROP TABLE IF EXISTS bcts_staging.ACTIVITY_CLASS;
CREATE TABLE bcts_staging.ACTIVITY_CLASS AS
DROP VIEW IF EXISTS bcts_staging.ACTIVITY_CLASS;
CREATE VIEW bcts_staging.ACTIVITY_CLASS AS
SELECT * FROM lrm_replication.ACTIVITY_CLASS;

DROP TABLE IF EXISTS bcts_staging.ACTIVITY_TYPE;
CREATE TABLE bcts_staging.ACTIVITY_TYPE AS
DROP VIEW IF EXISTS bcts_staging.ACTIVITY_TYPE;
CREATE VIEW bcts_staging.ACTIVITY_TYPE AS
SELECT * FROM lrm_replication.ACTIVITY_TYPE;

DROP TABLE IF EXISTS bcts_staging.ACTIVITY;
CREATE TABLE bcts_staging.ACTIVITY AS
DROP VIEW IF EXISTS bcts_staging.ACTIVITY;
CREATE VIEW bcts_staging.ACTIVITY AS
SELECT * FROM lrm_replication.ACTIVITY;


DROP TABLE IF EXISTS bcts_staging.annual_developed_volume;
DROP VIEW IF EXISTS bcts_staging.annual_developed_volume;

CREATE TABLE bcts_staging.annual_developed_volume AS
CREATE VIEW bcts_staging.annual_developed_volume AS
WITH annual_developed_volume AS
(
SELECT DISTINCT
Expand Down Expand Up @@ -174,7 +174,7 @@ ORDER BY
block
;

DROP TABLE IF EXISTS bcts_reporting.annual_developed_volume;
DROP VIEW IF EXISTS bcts_reporting.annual_developed_volume;

CREATE TABLE bcts_reporting.annual_developed_volume AS
SELECT * FROM bcts_staging.annual_developed_volume;
SELECT * FROM bcts_staging.annual_developed_volume;

0 comments on commit afe6674

Please sign in to comment.