Generate Documentation
CIIDCIID-ReportsG3GitHub
  • Introduction to Generate
  • User Guide
    • Getting Started
      • Requesting Generate
      • User Roles and Logging In
      • Navigating Generate
    • Resources
    • Data Population Summary
      • Producing Reports
      • Reports
      • Running Reports
    • Standard Reports
      • EDFacts Reports
        • Creating Submission Files
      • SPP/APR Reports
      • Reports Library
    • Settings
      • Toggle
      • Update
      • Metadata
      • Data Migration
    • Quality Assurance
    • Support
  • Developer Guides
    • Getting Started
    • Installation
      • OAuth Configuration
      • Configuring Metadata Updates
      • Subfolder configuration
      • Optional Installations
      • Azure Installation Guide
      • Upgrade
        • Generate Update
        • Optional Installations
    • Migration
      • Fact Type Table
        • Assessment Fact Type
        • Child Count Fact Type
        • Directory Fact Type
        • Discipline Fact Type
        • Exiting Fact Type
        • Membership
        • Staff
    • Generate Utilities
      • File Comparison
        • Loading Files
        • Run the File Comparison
        • Reviewing Results
        • Researching Mismatches
      • Staging Validation
        • Staging Table Validation Process
      • Rebuild Indexes
      • Cleanup Grades Offered
      • Cleanup Debug Tables
      • Source System Reference Data Mapping Utility
        • Source System Reference Data
      • Staging Table Snapshot
      • Fact Type Table Validation Process
      • Debug Views for Staging and the Fact tables
    • Generate Architecture
    • GitHub Guide
    • Discord Guide
    • Working With Generate Code
      • Migration Stored Procedures
        • Staging.RUN_DMC
        • RDS.Get_MembershipReportData
        • Staging.Staging-to-DimPeople
        • Staging.Staging-To-DimPeople_K12Students
        • Staging.Staging-to-FactK12ProgramParticipations
        • Staging.Staging-To-FactK12SeclusionsOrRestraints
        • Staging.Staging-to-FactK12StudentCounts_ChildCount
        • Staging.Staging-to-FactK12StudentCounts_Chronic
        • Staging.Staging-to-FactK12StudentCounts_Dropout
        • Staging.Staging-to-FactK12StudentCounts_GraduationRate
        • Staging.Staging-to-FactK12StudentCounts_Homeless
        • Staging.Staging-to-FactK12StudentCounts_HSGradPSEnroll
        • Staging.Staging-to-FactK12StudentCounts_Membership
        • Staging.Staging-to-FactK12StudentCounts_MigrantEducationProgram
        • Staging.Staging-to-FactK12StudentCounts_NeglectedOrDelinquent
        • Staging.Staging-to-FactK12StudentCounts_SpecEdExit
        • Staging.Staging-to-FactK12StudentCourseSections
        • Staging.Staging-to-FactK12StudentDisciplines
        • Staging.Staging-to-FactK12StudentEnrollments
        • Staging.Staging-To-FactSpecialEducation
      • Unit Test By File Spec
        • App.DimK12Staff_TestCase
        • App.DimK12Students_TestCase
        • App.FS002_TestCase
        • App.FS005_TestCase
        • App.FS006_TestCase
        • App.FS007_TestCase
        • App.FS009_TestCase
        • App.FS032_TestCase
        • App.FS033_TestCase
        • App.FS040_TestCase
  • Release Notes
    • Introduction
    • Release Notes 12.4
    • Release Notes 12.3
    • Release Notes 12.2
    • Release Notes 12.1
    • Archive
      • Release Notes 12.0
      • Release Notes 11.4
      • Release Notes 11.3
      • Release Notes 11.2
      • Release Notes 11.1
      • Release Notes 11.0
      • Release Notes 5.3
        • Generate 5.3 Office Hour
      • Release Notes 5.2
        • Generate 5.2 Office Hour
      • Release Notes 5.1
        • Generate 5.1 Office Hour
      • Release Notes 5.0
        • Generate 5.0 Office Hour
      • Release Notes 4.1
      • Release Notes 4.0
      • Release Notes 3.8
      • Release Notes 3.7
      • Release Notes 3.6
      • Release Notes 3.5
      • Release Notes 3.4
      • Release Notes 3.3
      • Release Notes 3.2
      • Release Notes 3.1
      • Release Notes 3.0
      • Release Notes 2.4
    • Release Notes 12.3
  • Hot Fixes
    • Hot Fix - 4/13/2023
Powered by GitBook
On this page
  • Overview & Purpose
  • Business Context
  • Parameters
  • Source Tables
  • Temporary Tables
  • Potential Improvements
  • Execution Steps

Was this helpful?

Edit on GitHub
  1. Developer Guides
  2. Working With Generate Code
  3. Unit Test By File Spec

App.DimK12Students_TestCase

Overview & Purpose

This stored procedure is designed to test the integrity of student data matching between the Staging.K12Enrollment table and the RDS.DimK12Students dimension table. It creates or references a unit test record, performs a match between staging and dimension tables, and records the test results in App.SqlUnitTestCaseResult.

Main Functions:

  • Student Data Matching Test

    To verify that student records in the staging table can be properly matched with corresponding records in the dimension table based on multiple matching criteria.

Key Calculations:

  • Student Data Matching Test: Compares the total count of student records with the count of successfully matched records

    Formula: COUNT(*) = COUNT(*) WHERE DimK12StudentId IS NOT NULL

    Business Significance: Ensures data integrity and proper relationship between staging and dimension tables

    Example: If 100 students exist in the staging table and all 100 match in the dimension table, the test passes

Data Transformations:

  • Joining staging enrollment data with dimension student data based on multiple matching criteria

  • Creating a temporary table to store the match results

  • Recording test results in the unit test results table

Expected Output:

A record in App.SqlUnitTestCaseResult indicating whether all student records in the staging table were successfully matched with records in the dimension table

Business Context

System: K-12 Education Data Warehouse

Necessity: Ensures data quality and integrity between staging and production tables for student information

Business Rules:

  • Student records must match on state identifier, name fields, sex, birth date, cohort, and enrollment dates

  • Missing values are handled by converting them to standard placeholders for comparison

Result Usage:

Test results are used to validate ETL processes and data quality for the student dimension

Execution Frequency:

Likely executed as part of ETL validation or on-demand testing

Critical Periods:

  • During data loads

  • Before reporting periods

  • After schema or ETL process changes

Parameters

Source Tables

Staging.K12Enrollment

Business Purpose: Stores staging data for K-12 student enrollment information

Columns:

Name
Data Type
Business Purpose

Student_Identifier_State

Unknown

Unique identifier for a student at the state level

LEA_Identifier_State

Unknown

Identifier for Local Education Agency (school district)

School_Identifier_State

Unknown

Identifier for the specific school

FirstName

Unknown

Student's first name

MiddleName

Unknown

Student's middle name

LastName

Unknown

Student's last name

Birthdate

Date

Student's date of birth

Sex

Unknown

Student's sex/gender

EnrollmentEntryDate

DateTime

Date when student enrolled

EnrollmentExitDate

DateTime

Date when student exited enrollment

CohortGraduationYear

Integer

Expected graduation year for student cohort

RDS.DimK12Students

Business Purpose: Dimension table storing K-12 student information

Columns:

Name
Data Type
Business Purpose

DimK12StudentId

Integer

Surrogate key for the student dimension

StateStudentIdentifier

Unknown

Unique identifier for a student at the state level

FirstName

Unknown

Student's first name

MiddleName

Unknown

Student's middle name

LastName

Unknown

Student's last name

SexCode

Unknown

Student's sex/gender code

BirthDate

Date

Student's date of birth

Cohort

Integer

Expected graduation year for student cohort

RecordStartDateTime

DateTime

Start date/time for the student record

App.SqlUnitTest

Business Purpose: Stores metadata about unit tests for SQL objects

Columns:

Name
Data Type
Business Purpose

SqlUnitTestId

Integer

Primary key for the unit test

UnitTestName

String

Descriptive name for the unit test

StoredProcedureName

String

Name of the stored procedure being tested

TestScope

String

Scope or area of the test

IsActive

Bit

Indicates if the test is active

App.SqlUnitTestCaseResult

Business Purpose: Stores results of unit test case executions

Columns:

Name
Data Type
Business Purpose

SqlUnitTestId

Integer

Foreign key to the unit test metadata

TestCaseName

String

Name of the specific test case

TestCaseDetails

String

Detailed description of the test case

ExpectedResult

Integer

Expected numeric result of the test

ActualResult

Integer

Actual numeric result of the test

Passed

Bit

Indicates if the test passed

TestDateTime

DateTime

When the test was executed

Temporary Tables

#Students

Purpose: Temporarily stores the results of matching student records between staging and dimension tables

Columns:

Name
Data Type
Purpose/Calculation

Student_Identifier_State

Unknown

Direct copy from Staging.K12Enrollment

LEA_Identifier_State

Unknown

Direct copy from Staging.K12Enrollment

School_Identifier_State

Unknown

Direct copy from Staging.K12Enrollment

FirstName

Unknown

Direct copy from Staging.K12Enrollment

MiddleName

Unknown

Direct copy from Staging.K12Enrollment

LastName

Unknown

Direct copy from Staging.K12Enrollment

Birthdate

Date

Direct copy from Staging.K12Enrollment

Sex

Unknown

Direct copy from Staging.K12Enrollment

RecordStartDateTime

DateTime

Copied from Staging.K12Enrollment.EnrollmentEntryDate

RecordEndDateTime

DateTime

Copied from Staging.K12Enrollment.EnrollmentExitDate

DimK12StudentId

Integer

Copied from RDS.DimK12Students when match is found

Potential Improvements

Error Handling

Description: Add TRY/CATCH blocks to handle potential errors during execution

Benefits: Prevents procedure failures and provides better diagnostics

Priority: Medium

Performance

Description: Add indexes to the temporary table for better performance

Benefits: Faster execution for large datasets

Priority: Low

Code Structure

Description: Modularize the code by creating separate procedures for test setup and execution

Benefits: Improved maintainability and reusability

Priority: Low

Documentation

Description: Add more detailed comments explaining the matching logic and test criteria

Benefits: Improved maintainability and knowledge transfer

Priority: Medium

Execution Steps

Step 1: Define or retrieve the unit test metadata

Input Data: App.SqlUnitTest table

Transformations: None

IF NOT EXISTS (SELECT 1 FROM App.SqlUnitTest WHERE UnitTestName = 'DimK12Students_UnitTestCase') BEGIN ... END ELSE BEGIN ... END

Step 2: Clear previous test results

Input Data: App.SqlUnitTestCaseResult table

Transformations: None

DELETE FROM App.SqlUnitTestCaseResult WHERE SqlUnitTestId = @SqlUnitTestId

Step 3: Create temporary table with student data and match results

Input Data: Staging.K12Enrollment and RDS.DimK12Students tables

Transformations: Join between staging and dimension tables with multiple match conditions

SELECT ... INTO #Students FROM Staging.K12Enrollment ske LEFT JOIN RDS.DimK12Students rds ON ...

Step 4: Record test results

Input Data: #Students temporary table

Transformations: Aggregation to count total and matched records

INSERT INTO App.SqlUnitTestCaseResult (...) SELECT ...

Step 5: Clean up temporary resources

Input Data: #Students temporary table

Transformations: None

DROP TABLE #Students

PreviousApp.DimK12Staff_TestCaseNextApp.FS002_TestCase

Was this helpful?