-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BIA-864] Adjusts SessionKey on AcademicTimePeriodDim to meet DS3 def…
…inition
- Loading branch information
1 parent
d2bd545
commit ac58904
Showing
8 changed files
with
265 additions
and
4 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
...i.AnalyticsMiddleTier.DataStandard31/Base/MSSQL/0040-View-AcademicTimePeriodDim-Alter.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
-- Licensed to the Ed-Fi Alliance under one or more agreements. | ||
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
-- See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'analytics' AND TABLE_NAME = 'AcademicTimePeriodDim') | ||
BEGIN | ||
DROP VIEW analytics.AcademicTimePeriodDim | ||
END | ||
GO | ||
|
||
CREATE VIEW analytics.AcademicTimePeriodDim | ||
AS | ||
SELECT | ||
FORMATMESSAGE( | ||
'%s-%s-%s-%s-%s', | ||
CAST(Session.SchoolId as VARCHAR), | ||
CAST(Session.SchoolYear as VARCHAR), | ||
CAST(Session.TermDescriptorId as VARCHAR), | ||
CAST(GradingPeriod.GradingPeriodDescriptorId as VARCHAR), | ||
CONVERT(VARCHAR, GradingPeriod.BeginDate, 112) | ||
) as AcademicTimePeriodKey, | ||
CAST(SchoolYearType.SchoolYear as VARCHAR) as SchoolYear, | ||
SchoolYearType.SchoolYearDescription as SchoolYearName, | ||
SchoolYearType.CurrentSchoolYear as IsCurrentSchoolYear, | ||
CAST(Session.SchoolId as VARCHAR) as SchoolKey, | ||
FORMATMESSAGE( | ||
'%s-%s-%s', | ||
CAST(Session.SchoolId as VARCHAR), | ||
CAST(Session.SchoolYear as VARCHAR), | ||
CAST(Session.SessionName as VARCHAR) | ||
) as SessionKey, | ||
Session.SessionName, | ||
Descriptor.Description as TermName, | ||
FORMATMESSAGE( | ||
'%s-%s-%s', | ||
CAST(GradingPeriod.GradingPeriodDescriptorId as VARCHAR), | ||
CAST(GradingPeriod.SchoolId as VARCHAR), | ||
CONVERT(VARCHAR, GradingPeriod.BeginDate, 112) | ||
) as GradingPeriodKey, | ||
gpDescriptor.Description as GradingPeriodName, | ||
( | ||
SELECT MAX(MaxLastModifiedDate) | ||
FROM ( | ||
VALUES | ||
(SchoolYearType.LastModifiedDate), | ||
(Session.LastModifiedDate), | ||
(GradingPeriod.LastModifiedDate) | ||
) as VALUE(MaxLastModifiedDate) | ||
) as LastModifiedDate | ||
FROM | ||
edfi.SchoolYearType | ||
INNER JOIN | ||
edfi.Session | ||
ON | ||
SchoolYearType.SchoolYear = Session.SchoolYear | ||
INNER JOIN | ||
edfi.Descriptor | ||
ON | ||
Session.TermDescriptorId = Descriptor.DescriptorId | ||
INNER JOIN | ||
edfi.SessionGradingPeriod | ||
ON | ||
Session.SchoolYear = SessionGradingPeriod.SchoolYear | ||
AND | ||
Session.SessionName = SessionGradingPeriod.SessionName | ||
AND | ||
Session.SchoolId = SessionGradingPeriod.SchoolId | ||
INNER JOIN | ||
edfi.GradingPeriod | ||
ON | ||
SessionGradingPeriod.GradingPeriodDescriptorId = GradingPeriod.GradingPeriodDescriptorId | ||
AND | ||
SessionGradingPeriod.PeriodSequence = GradingPeriod.PeriodSequence | ||
AND | ||
SessionGradingPeriod.SchoolId = GradingPeriod.SchoolId | ||
AND | ||
Session.SchoolYear = GradingPeriod.SchoolYear | ||
INNER JOIN | ||
edfi.Descriptor as gpDescriptor | ||
ON | ||
GradingPeriod.GradingPeriodDescriptorId = gpDescriptor.DescriptorId | ||
|
||
GO |
84 changes: 84 additions & 0 deletions
84
...i.AnalyticsMiddleTier.DataStandard32/Base/MSSQL/0040-View-AcademicTimePeriodDim-Alter.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
-- Licensed to the Ed-Fi Alliance under one or more agreements. | ||
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
-- See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'analytics' AND TABLE_NAME = 'AcademicTimePeriodDim') | ||
BEGIN | ||
DROP VIEW analytics.AcademicTimePeriodDim | ||
END | ||
GO | ||
|
||
CREATE VIEW analytics.AcademicTimePeriodDim | ||
AS | ||
SELECT | ||
FORMATMESSAGE( | ||
'%s-%s-%s-%s-%s', | ||
CAST(Session.SchoolId as VARCHAR), | ||
CAST(Session.SchoolYear as VARCHAR), | ||
CAST(Session.TermDescriptorId as VARCHAR), | ||
CAST(GradingPeriod.GradingPeriodDescriptorId as VARCHAR), | ||
CONVERT(VARCHAR, GradingPeriod.BeginDate, 112) | ||
) as AcademicTimePeriodKey, | ||
CAST(SchoolYearType.SchoolYear as VARCHAR) as SchoolYear, | ||
SchoolYearType.SchoolYearDescription as SchoolYearName, | ||
SchoolYearType.CurrentSchoolYear as IsCurrentSchoolYear, | ||
CAST(Session.SchoolId as VARCHAR) as SchoolKey, | ||
FORMATMESSAGE( | ||
'%s-%s-%s', | ||
CAST(Session.SchoolId as VARCHAR), | ||
CAST(Session.SchoolYear as VARCHAR), | ||
CAST(Session.SessionName as VARCHAR) | ||
) as SessionKey, | ||
Session.SessionName, | ||
Descriptor.Description as TermName, | ||
FORMATMESSAGE( | ||
'%s-%s-%s', | ||
CAST(GradingPeriod.GradingPeriodDescriptorId as VARCHAR), | ||
CAST(GradingPeriod.SchoolId as VARCHAR), | ||
CONVERT(VARCHAR, GradingPeriod.BeginDate, 112) | ||
) as GradingPeriodKey, | ||
gpDescriptor.Description as GradingPeriodName, | ||
( | ||
SELECT MAX(MaxLastModifiedDate) | ||
FROM ( | ||
VALUES | ||
(SchoolYearType.LastModifiedDate), | ||
(Session.LastModifiedDate), | ||
(GradingPeriod.LastModifiedDate) | ||
) as VALUE(MaxLastModifiedDate) | ||
) as LastModifiedDate | ||
FROM | ||
edfi.SchoolYearType | ||
INNER JOIN | ||
edfi.Session | ||
ON | ||
SchoolYearType.SchoolYear = Session.SchoolYear | ||
INNER JOIN | ||
edfi.Descriptor | ||
ON | ||
Session.TermDescriptorId = Descriptor.DescriptorId | ||
INNER JOIN | ||
edfi.SessionGradingPeriod | ||
ON | ||
Session.SchoolYear = SessionGradingPeriod.SchoolYear | ||
AND | ||
Session.SessionName = SessionGradingPeriod.SessionName | ||
AND | ||
Session.SchoolId = SessionGradingPeriod.SchoolId | ||
INNER JOIN | ||
edfi.GradingPeriod | ||
ON | ||
SessionGradingPeriod.GradingPeriodDescriptorId = GradingPeriod.GradingPeriodDescriptorId | ||
AND | ||
SessionGradingPeriod.PeriodSequence = GradingPeriod.PeriodSequence | ||
AND | ||
SessionGradingPeriod.SchoolId = GradingPeriod.SchoolId | ||
AND | ||
Session.SchoolYear = GradingPeriod.SchoolYear | ||
INNER JOIN | ||
edfi.Descriptor as gpDescriptor | ||
ON | ||
GradingPeriod.GradingPeriodDescriptorId = gpDescriptor.DescriptorId | ||
|
||
GO |
78 changes: 78 additions & 0 deletions
78
...lyticsMiddleTier.DataStandard32/Base/PostgreSQL/0042-View-AcademicTimePeriodDim-Alter.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
-- Licensed to the Ed-Fi Alliance under one or more agreements. | ||
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
-- See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
DROP VIEW IF EXISTS analytics.AcademicTimePeriodDim; | ||
|
||
CREATE VIEW analytics.AcademicTimePeriodDim | ||
AS | ||
SELECT | ||
FORMAT( | ||
'%s-%s-%s-%s-%s', | ||
CAST(Session.SchoolId as VARCHAR), | ||
CAST(Session.SchoolYear as VARCHAR), | ||
CAST(Session.TermDescriptorId as VARCHAR), | ||
CAST(GradingPeriod.GradingPeriodDescriptorId as VARCHAR), | ||
to_char(GradingPeriod.BeginDate, 'yyyymmdd') | ||
) as AcademicTimePeriodKey, | ||
CAST(SchoolYearType.SchoolYear as VARCHAR) as SchoolYear, | ||
SchoolYearType.SchoolYearDescription as SchoolYearName, | ||
SchoolYearType.CurrentSchoolYear as IsCurrentSchoolYear, | ||
CAST(Session.SchoolId as VARCHAR) as SchoolKey, | ||
FORMAT( | ||
'%s-%s-%s', | ||
CAST(Session.SchoolId as VARCHAR), | ||
CAST(Session.SchoolYear as VARCHAR), | ||
CAST(Session.SessionName as VARCHAR) | ||
) as SessionKey, | ||
Session.SessionName, | ||
Descriptor.Description as TermName, | ||
FORMAT( | ||
'%s-%s-%s', | ||
CAST(GradingPeriod.GradingPeriodDescriptorId as VARCHAR), | ||
CAST(GradingPeriod.SchoolId as VARCHAR), | ||
to_char(GradingPeriod.BeginDate, 'yyyymmdd') | ||
) as GradingPeriodKey, | ||
gpDescriptor.Description as GradingPeriodName, | ||
( | ||
SELECT MAX(MaxLastModifiedDate) | ||
FROM ( | ||
VALUES | ||
(SchoolYearType.LastModifiedDate), | ||
(Session.LastModifiedDate), | ||
(GradingPeriod.LastModifiedDate) | ||
) as VALUE(MaxLastModifiedDate) | ||
) as LastModifiedDate | ||
FROM | ||
edfi.SchoolYearType | ||
INNER JOIN | ||
edfi.Session | ||
ON | ||
SchoolYearType.SchoolYear = Session.SchoolYear | ||
INNER JOIN | ||
edfi.Descriptor | ||
ON | ||
Session.TermDescriptorId = Descriptor.DescriptorId | ||
INNER JOIN | ||
edfi.SessionGradingPeriod | ||
ON | ||
Session.SchoolYear = SessionGradingPeriod.SchoolYear | ||
AND | ||
Session.SessionName = SessionGradingPeriod.SessionName | ||
AND | ||
Session.SchoolId = SessionGradingPeriod.SchoolId | ||
INNER JOIN | ||
edfi.GradingPeriod | ||
ON | ||
SessionGradingPeriod.GradingPeriodDescriptorId = GradingPeriod.GradingPeriodDescriptorId | ||
AND | ||
SessionGradingPeriod.PeriodSequence = GradingPeriod.PeriodSequence | ||
AND | ||
SessionGradingPeriod.SchoolId = GradingPeriod.SchoolId | ||
AND | ||
Session.SchoolYear = GradingPeriod.SchoolYear | ||
INNER JOIN | ||
edfi.Descriptor as gpDescriptor | ||
ON | ||
GradingPeriod.GradingPeriodDescriptorId = gpDescriptor.DescriptorId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
</Query> | ||
<Result> | ||
<SessionKey> | ||
867530010-2012-1 | ||
867530010-2012-1 | ||
</SessionKey> | ||
</Result> | ||
</TestCase> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...dleTier.Tests/TestCases/AcademicTimePeriodDim/PostgreSQL/v_3_2/should_have_SessionKey.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<TestCase> | ||
<DBMS>Any</DBMS> | ||
<ControlDataInsertion> | ||
</ControlDataInsertion> | ||
<Query> | ||
SELECT SessionKey | ||
FROM analytics.AcademicTimePeriodDim | ||
WHERE SessionName = 'Grading period is the last modified'; | ||
</Query> | ||
<Result> | ||
<SessionKey> | ||
867530010-2012-Grading period is the last modified | ||
</SessionKey> | ||
</Result> | ||
</TestCase> |