From 850a156ac5c08281bec9833152ee695baf825220 Mon Sep 17 00:00:00 2001
From: Ruhanga <41738040+Ruhanga@users.noreply.github.com>
Date: Thu, 23 May 2024 11:33:03 +0300
Subject: [PATCH] KH-541: Ozone Analytics Queries to flatten Locations (#9)
---
analytics/dsl/export/queries/locations.sql | 1 +
analytics/dsl/export/tables/locations.sql | 37 +++++++++++++++++
.../dsl/flattening/queries/locations.sql | 38 +++++++++++++++++
.../analytics/changelogs/0001-init.xml | 41 +++++++++++++++++++
4 files changed, 117 insertions(+)
create mode 100644 analytics/dsl/export/queries/locations.sql
create mode 100644 analytics/dsl/export/tables/locations.sql
create mode 100755 analytics/dsl/flattening/queries/locations.sql
diff --git a/analytics/dsl/export/queries/locations.sql b/analytics/dsl/export/queries/locations.sql
new file mode 100644
index 0000000..bed773e
--- /dev/null
+++ b/analytics/dsl/export/queries/locations.sql
@@ -0,0 +1 @@
+INSERT into locations SELECT t.* from analytics.analytics.locations t
\ No newline at end of file
diff --git a/analytics/dsl/export/tables/locations.sql b/analytics/dsl/export/tables/locations.sql
new file mode 100644
index 0000000..be0a1e0
--- /dev/null
+++ b/analytics/dsl/export/tables/locations.sql
@@ -0,0 +1,37 @@
+CREATE TABLE locations (
+ location_id BIGINT,
+ name VARCHAR,
+ description VARCHAR,
+ address1 VARCHAR,
+ address2 VARCHAR,
+ city_village VARCHAR,
+ state_province VARCHAR,
+ postal_code VARCHAR,
+ country VARCHAR,
+ latitude VARCHAR,
+ longitude VARCHAR,
+ creator BIGINT,
+ date_created TIMESTAMP,
+ county_district VARCHAR,
+ address3 VARCHAR,
+ address4 VARCHAR,
+ address5 VARCHAR,
+ address6 VARCHAR,
+ retired BOOLEAN,
+ retired_by BIGINT,
+ date_retired TIMESTAMP,
+ retire_reason VARCHAR,
+ parent_location BIGINT,
+ uuid VARCHAR,
+ changed_by BIGINT,
+ date_changed TIMESTAMP,
+ address7 VARCHAR,
+ address8 VARCHAR,
+ address9 VARCHAR,
+ address10 VARCHAR,
+ address11 VARCHAR,
+ address12 VARCHAR,
+ address13 VARCHAR,
+ address14 VARCHAR,
+ address15 VARCHAR
+)
\ No newline at end of file
diff --git a/analytics/dsl/flattening/queries/locations.sql b/analytics/dsl/flattening/queries/locations.sql
new file mode 100755
index 0000000..710ea15
--- /dev/null
+++ b/analytics/dsl/flattening/queries/locations.sql
@@ -0,0 +1,38 @@
+SELECT
+ location_id,
+ name,
+ description,
+ address1,
+ address2,
+ city_village,
+ state_province,
+ postal_code,
+ country,
+ latitude,
+ longitude,
+ creator,
+ date_created,
+ county_district,
+ address3,
+ address4,
+ address5,
+ address6,
+ retired,
+ retired_by,
+ date_retired,
+ retire_reason,
+ parent_location,
+ uuid,
+ changed_by,
+ date_changed,
+ address7,
+ address8,
+ address9,
+ address10,
+ address11,
+ address12,
+ address13,
+ address14,
+ address15
+FROM
+ location
\ No newline at end of file
diff --git a/analytics/liquibase/analytics/changelogs/0001-init.xml b/analytics/liquibase/analytics/changelogs/0001-init.xml
index 2881870..4790428 100644
--- a/analytics/liquibase/analytics/changelogs/0001-init.xml
+++ b/analytics/liquibase/analytics/changelogs/0001-init.xml
@@ -333,4 +333,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file