Skip to content

Commit c15cee1

Browse files
add staging tables
1 parent 0ebb286 commit c15cee1

44 files changed

Lines changed: 297 additions & 115 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

sql/SPROC_test_move_data_to_permanent_tables.sql

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,52 @@ BEGIN
2323
SELECT TOP 0 * INTO dbo.staging_test_table FROM dbo.test_table;
2424

2525
INSERT INTO staging_test_table VALUES(1, 2, 'test');
26-
INSERT INTO expected_test_table VALUES(1, 2, 'test');
26+
INSERT INTO expected_test_table VALUES(2, 2, 'test');
2727
INSERT INTO watermark_test VALUES('test_table');
2828

2929
EXEC dbo.move_data_to_permanent_tables 'watermark_test';
3030

3131

32+
DECLARE @Expected AS VARCHAR(100)
33+
DECLARE @Actual AS VARCHAR(100)
34+
35+
SET @Expected = (SELECT COUNT(*) FROM expected_test_table)
36+
SET @Actual = (SELECT COUNT(*) FROM test_table)
3237
-- Validate test table has the same number of rows as expected table
3338
IF (SELECT COUNT(*) FROM test_table) = (SELECT COUNT(*) FROM expected_test_table)
34-
RAISERROR ('Equal', 0, 1) WITH NOWAIT
35-
ELSE
36-
RAISERROR ('Not Equal', 0, 1);
39+
RAISERROR ('Expected and Actual Count is Equal', 0, 1) WITH NOWAIT;
40+
ELSE
41+
RAISERROR ('Actual Value(%s) is not Equal to expected value (%s) ', 0, 1, @Actual, @Expected) WITH NOWAIT;
3742

3843
-- Validate test table has the same value for col1 as expected table
44+
SET @Expected = (SELECT col1 FROM expected_test_table)
45+
SET @Actual = (SELECT col1 FROM test_table)
3946
IF (SELECT col1 FROM test_table) = (SELECT col1 FROM expected_test_table)
40-
RAISERROR ('Equal', 0, 1) WITH NOWAIT;
47+
RAISERROR ('Actual Col 1 is Equal to Expected Col 1', 0, 1) WITH NOWAIT;
4148
ELSE
42-
RAISERROR ('Not Equal', 0, 1);
49+
RAISERROR ('Actual Value(%s) is not Equal to expected value (%s) ', 0, 1, @Actual, @Expected) WITH NOWAIT;
4350

4451

4552
-- Validate test table has the same value for col2 as expected table
53+
SET @Expected = (SELECT col2 FROM expected_test_table)
54+
SET @Actual = (SELECT col2 FROM test_table)
4655
IF (SELECT col2 FROM test_table) = (SELECT col2 FROM expected_test_table)
47-
RAISERROR ('Equal', 0, 1) WITH NOWAIT
56+
RAISERROR ('Actual Col 2 is Equal to Expected Col 2', 0, 1) WITH NOWAIT;
4857
ELSE
49-
RAISERROR ('Not Equal', 0, 1);
58+
RAISERROR ('Actual Value(%s) is not Equal to expected value (%s) ', 0, 1, @Actual, @Expected) WITH NOWAIT;
5059

5160
-- Validate test table has the same value for col3 as expected table
61+
SET @Expected = (SELECT col3 FROM expected_test_table)
62+
SET @Actual = (SELECT col3 FROM test_table)
5263
IF (SELECT col3 FROM test_table) = (SELECT col3 FROM expected_test_table)
53-
RAISERROR ('Equal', 0, 1) WITH NOWAIT
64+
RAISERROR ('Actual Col 3 is Equal to Expected Col 3', 0, 1) WITH NOWAIT;
5465
ELSE
55-
RAISERROR ('Not Equal', 0, 1);
56-
66+
RAISERROR ('Actual Value(%s) is not Equal to expected value (%s) ', 0, 1, @Actual, @Expected) WITH NOWAIT;
67+
5768
DROP TABLE watermark_test;
5869
DROP TABLE test_table;
5970
DROP TABLE staging_test_table;
6071
DROP TABLE expected_test_table;
72+
73+
6174
END

sql/dacpac/dbo/StoredProcedures/test_move_data_to_permanent_tables.sql

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,42 @@ BEGIN
2929
EXEC dbo.move_data_to_permanent_tables 'watermark_test';
3030

3131

32+
DECLARE @Expected AS VARCHAR(100)
33+
DECLARE @Actual AS VARCHAR(100)
34+
35+
SET @Expected = (SELECT COUNT(*) FROM expected_test_table)
36+
SET @Actual = (SELECT COUNT(*) FROM test_table)
3237
-- Validate test table has the same number of rows as expected table
3338
IF (SELECT COUNT(*) FROM test_table) = (SELECT COUNT(*) FROM expected_test_table)
34-
RAISERROR ('Equal', 0, 1) WITH NOWAIT;
35-
ELSE
36-
RAISERROR ('Not Equal', 0, 1);
39+
RAISERROR ('Expected and Actual Count is Equal', 0, 1) WITH NOWAIT;
40+
ELSE
41+
RAISERROR ('Actual Value(%s) is not Equal to expected value (%s) ', 0, 1, @Actual, @Expected) WITH NOWAIT;
3742

3843
-- Validate test table has the same value for col1 as expected table
44+
SET @Expected = (SELECT col1 FROM expected_test_table)
45+
SET @Actual = (SELECT col1 FROM test_table)
3946
IF (SELECT col1 FROM test_table) = (SELECT col1 FROM expected_test_table)
40-
RAISERROR ('Equal', 0, 1) WITH NOWAIT;
47+
RAISERROR ('Actual Col 1 is Equal to Expected Col 1', 0, 1) WITH NOWAIT;
4148
ELSE
42-
RAISERROR ('Not Equal', 0, 1);
49+
RAISERROR ('Actual Value(%s) is not Equal to expected value (%s) ', 0, 1, @Actual, @Expected) WITH NOWAIT;
4350

4451

4552
-- Validate test table has the same value for col2 as expected table
53+
SET @Expected = (SELECT col2 FROM expected_test_table)
54+
SET @Actual = (SELECT col2 FROM test_table)
4655
IF (SELECT col2 FROM test_table) = (SELECT col2 FROM expected_test_table)
47-
RAISERROR ('Equal', 0, 1) WITH NOWAIT;
56+
RAISERROR ('Actual Col 2 is Equal to Expected Col 2', 0, 1) WITH NOWAIT;
4857
ELSE
49-
RAISERROR ('Not Equal', 0, 1);
58+
RAISERROR ('Actual Value(%s) is not Equal to expected value (%s) ', 0, 1, @Actual, @Expected) WITH NOWAIT;
5059

5160
-- Validate test table has the same value for col3 as expected table
61+
SET @Expected = (SELECT col3 FROM expected_test_table)
62+
SET @Actual = (SELECT col3 FROM test_table)
5263
IF (SELECT col3 FROM test_table) = (SELECT col3 FROM expected_test_table)
53-
RAISERROR ('Equal', 0, 1) WITH NOWAIT;
64+
RAISERROR ('Actual Col 3 is Equal to Expected Col 3', 0, 1) WITH NOWAIT;
5465
ELSE
55-
RAISERROR ('Not Equal', 0, 1);
56-
66+
RAISERROR ('Actual Value(%s) is not Equal to expected value (%s) ', 0, 1, @Actual, @Expected) WITH NOWAIT;
67+
5768
DROP TABLE watermark_test;
5869
DROP TABLE test_table;
5970
DROP TABLE staging_test_table;

sql/dacpac/dbo/Tables/metadata.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CREATE TABLE [dbo].[metadata] (
2+
[metadata_concept_id] INT NOT NULL,
3+
[metadata_type_concept_id] INT NOT NULL,
4+
[name] VARCHAR (250) NOT NULL,
5+
[value_as_string] VARCHAR (MAX) NULL,
6+
[value_as_concept_id] INT NULL,
7+
[metadata_date] DATE NULL,
8+
[metadata_datetime] DATETIME2 (7) NULL
9+
);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE TABLE [dbo].[staging_attribute_definition] (
2+
[attribute_definition_id] INT NOT NULL,
3+
[attribute_name] VARCHAR (255) NOT NULL,
4+
[attribute_description] VARCHAR (MAX) NULL,
5+
[attribute_type_concept_id] INT NOT NULL,
6+
[attribute_syntax] VARCHAR (MAX) NULL,
7+
);
8+

sql/dacpac/dbo/Tables/staging_care_site.sql

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,3 @@ CREATE TABLE [dbo].[staging_care_site] (
66
[care_site_source_value] VARCHAR (50) NULL,
77
[place_of_service_source_value] VARCHAR (50) NULL
88
);
9-
10-
11-
GO
12-

sql/dacpac/dbo/Tables/staging_cdm_source.sql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,3 @@ CREATE TABLE [dbo].[staging_cdm_source] (
1111
[vocabulary_version] VARCHAR (20) NULL
1212
);
1313

14-
15-
GO
16-
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE TABLE [dbo].[staging_cohort] (
2+
[cohort_definition_id] INT NOT NULL,
3+
[subject_id] INT NOT NULL,
4+
[cohort_start_date] DATE NOT NULL,
5+
[cohort_end_date] DATE NOT NULL,
6+
);
7+
8+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CREATE TABLE [dbo].[staging_cohort_attribute] (
2+
[cohort_definition_id] INT NOT NULL,
3+
[cohort_start_date] DATE NOT NULL,
4+
[cohort_end_date] DATE NOT NULL,
5+
[subject_id] INT NOT NULL,
6+
[attribute_definition_id] INT NOT NULL,
7+
[value_as_number] FLOAT (53) NULL,
8+
[value_as_concept_id] INT NULL,
9+
);
10+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CREATE TABLE [dbo].[staging_cohort_definition] (
2+
[cohort_definition_id] INT NOT NULL,
3+
[cohort_definition_name] VARCHAR (255) NOT NULL,
4+
[cohort_definition_description] VARCHAR (MAX) NULL,
5+
[definition_type_concept_id] INT NOT NULL,
6+
[cohort_definition_syntax] VARCHAR (MAX) NULL,
7+
[subject_concept_id] INT NOT NULL,
8+
[cohort_initiation_date] DATE NULL,
9+
);
10+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CREATE TABLE [dbo].[staging_concept] (
2+
[concept_id] INT NOT NULL,
3+
[concept_name] VARCHAR (255) NOT NULL,
4+
[domain_id] VARCHAR (20) NOT NULL,
5+
[vocabulary_id] VARCHAR (20) NOT NULL,
6+
[concept_class_id] VARCHAR (20) NOT NULL,
7+
[standard_concept] VARCHAR (1) NULL,
8+
[concept_code] VARCHAR (50) NOT NULL,
9+
[valid_start_date] DATE NOT NULL,
10+
[valid_end_date] DATE NOT NULL,
11+
[invalid_reason] VARCHAR (1) NULL,
12+
);

0 commit comments

Comments
 (0)