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.DimK12Staff_TestCase

Overview & Purpose

This stored procedure is designed to test the integrity of K12 staff data by comparing records in the staging table with corresponding records in the dimension table. It creates a unit test case, executes the test, and records the results in a test tracking table.

Main Functions:

  • Unit Test Setup

    Creates or retrieves a unit test record in App.SqlUnitTest table

  • Data Comparison

    Compares staff records between staging and dimension tables

Key Calculations:

  • Unit Test Setup: Register the test case in the unit test tracking system

    Formula: INSERT INTO App.SqlUnitTest

    Business Significance: Ensures test cases are properly documented and tracked

    Example: UnitTestName = 'DimK12Staff_UnitTestCase'

  • Data Comparison: Verify that all staff records in staging have corresponding dimension records

    Formula: COUNT(*) = (SELECT COUNT(*) FROM #Staff WHERE DimPersonId IS NOT NULL)

    Business Significance: Ensures data integrity between staging and dimension tables

    Example: CASE WHEN COUNT(*) = (SELECT COUNT(*) FROM #Staff WHERE DimPersonId IS NOT NULL) THEN 1 ELSE 0 END

Data Transformations:

  • Joins staging K12 staff data with dimension people data based on StaffMemberIdentifierState and RecordStartDateTime

  • Creates a temporary table to store the joined data for analysis

Expected Output:

Test case results recorded in App.SqlUnitTestCaseResult table, indicating whether all staff records in staging have corresponding dimension records

Business Context

System: K12 Education Data Warehouse

Necessity: Ensures data quality and integrity for K12 staff data between staging and dimension tables

Business Rules:

  • Staff records should match between staging and dimension tables

  • Staff are identified by StaffMemberIdentifierState and RecordStartDateTime

  • Only active K12 staff records are considered (IsActiveK12Staff = 1)

Result Usage:

Test results are used to validate ETL processes and data integrity for K12 staff data

Execution Frequency:

Likely executed as part of ETL validation or regular data quality checks

Parameters

Source Tables

Staging.K12StaffAssignment

Business Purpose: Stores staging data for K12 staff assignments

Columns:

Name
Data Type
Business Purpose

StaffMemberIdentifierState

Unknown

Unique identifier for staff members at the state level

RecordStartDateTime

DateTime

Indicates when the staff record became effective

RDS.DimPeople

Business Purpose: Dimension table storing people data including K12 staff

Columns:

Name
Data Type
Business Purpose

DimPersonId

Unknown (likely INT or BIGINT)

Primary key for the dimension table

K12StaffStaffMemberIdentifierState

Unknown

Staff identifier that links to staging data

RecordStartDateTime

DateTime

Indicates when the dimension record became effective

IsActiveK12Staff

BIT

Flag indicating if the person is an active K12 staff member

App.SqlUnitTest

Business Purpose: Stores metadata about unit tests

Columns:

Name
Data Type
Business Purpose

SqlUnitTestId

INT

Primary key for unit test records

UnitTestName

VARCHAR or NVARCHAR

Descriptive name for the unit test

StoredProcedureName

VARCHAR or NVARCHAR

Name of the stored procedure being tested

TestScope

VARCHAR or NVARCHAR

Indicates the scope or area being tested

IsActive

BIT

Indicates if the test is currently active

App.SqlUnitTestCaseResult

Business Purpose: Stores results of unit test executions

Columns:

Name
Data Type
Business Purpose

SqlUnitTestId

INT

Foreign key to the unit test definition

TestCaseName

VARCHAR or NVARCHAR

Name of the specific test case

TestCaseDetails

VARCHAR or NVARCHAR

Detailed description of the test case

ExpectedResult

INT

The expected result value for the test

ActualResult

INT

The actual result value from the test execution

Passed

BIT

Indicates if the test passed (1) or failed (0)

TestDateTime

DATETIME

When the test was executed

Temporary Tables

#Staff

Purpose: Temporarily stores joined data between staging and dimension tables for analysis

Columns:

Name
Data Type
Purpose/Calculation

StaffMemberIdentifierState

Unknown (inherited from source)

Direct copy from Staging.K12StaffAssignment

RecordStartDateTime

DateTime

Direct copy from Staging.K12StaffAssignment

DimPersonId

Unknown (inherited from source)

Joined from RDS.DimPeople

Potential Improvements

Error Handling

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

Benefits: Improved reliability and easier troubleshooting

Priority: Medium

Documentation

Description: Add header comments explaining the procedure's purpose and parameters

Benefits: Improved maintainability and knowledge transfer

Priority: Low

Performance

Description: Add indexes to the temporary table for better performance

Benefits: Potentially faster execution for large datasets

Priority: Low

Functionality

Description: Add more detailed test cases to check specific aspects of the data

Benefits: More comprehensive testing and validation

Priority: Medium

Execution Steps

Step 1: Drop temporary table if it exists

Input Data: None

Transformations: None

IF OBJECT_ID('tempdb..#Staff') IS NOT NULL DROP TABLE #Staff

Step 2: Initialize variables and create/retrieve unit test record

Input Data: App.SqlUnitTest table

Transformations: None

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

Step 3: Clear previous test results

Input Data: App.SqlUnitTestCaseResult table

Transformations: None

DELETE FROM App.SqlUnitTestCaseResult WHERE SqlUnitTestId = @SqlUnitTestId

Step 4: Create temporary table with joined data

Input Data: Staging.K12StaffAssignment and RDS.DimPeople tables

Transformations: Left join between staging and dimension tables

SELECT ske.StaffMemberIdentifierState, ske.RecordStartDateTime, rds.DimPersonId INTO #Staff FROM...

Step 5: Insert test results

Input Data: #Staff temporary table

Transformations: Aggregation and comparison

INSERT INTO App.SqlUnitTestCaseResult (...) SELECT @SqlUnitTestId, 'Staff Match',...

PreviousUnit Test By File SpecNextApp.DimK12Students_TestCase

Was this helpful?