Skip to content

Default LastUpdated/LoadDate on EmployeeAccrualBalances#315

Open
rmartinsen-ucd wants to merge 1 commit into
mainfrom
rpm/accruals-lastupdated-default
Open

Default LastUpdated/LoadDate on EmployeeAccrualBalances#315
rmartinsen-ucd wants to merge 1 commit into
mainfrom
rpm/accruals-lastupdated-default

Conversation

@rmartinsen-ucd

@rmartinsen-ucd rmartinsen-ucd commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Problem

The RefreshEmployeeAccrualBalances ADF pipeline failed on the SQL sink with:

Cannot insert the value NULL into column 'LastUpdated', table 'WalterDev.dbo.EmployeeAccrualBalances'; column does not allow nulls.

The Copy activity uses ADF's auto-mapping (no explicit column list in the TabularTranslator), and the source sproc usp_GetEmployeeAccrualBalances doesn't return LastUpdated or LoadDate. So the upsert MERGE omits those columns. LastUpdated is NOT NULL with no default, so the insert blew up.

Fix

Add DEFAULT SYSUTCDATETIME() to both LastUpdated and LoadDate so the DB stamps the load time when ADF omits the columns. LastUpdated stays NOT NULL.

A trigger was considered but rejected: the NOT NULL check fires before an AFTER INSERT trigger, so it wouldn't help without an INSTEAD OF trigger — heavier and more surprising than a default.

Deploy note

For the existing table, the constraints can be applied directly:

ALTER TABLE dbo.EmployeeAccrualBalances
ADD CONSTRAINT DF_EmployeeAccrualBalances_LastUpdated DEFAULT SYSUTCDATETIME() FOR LastUpdated;

ALTER TABLE dbo.EmployeeAccrualBalances
ADD CONSTRAINT DF_EmployeeAccrualBalances_LoadDate DEFAULT SYSUTCDATETIME() FOR LoadDate;

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Enhanced database record management by implementing automatic UTC timestamp recording for employee accrual balance entries, ensuring consistent data tracking across the system.

The ADF RefreshEmployeeAccrualBalances upsert auto-maps columns by name,
and the source sproc usp_GetEmployeeAccrualBalances does not return
LastUpdated or LoadDate. With LastUpdated NOT NULL and no default, the
sink INSERT failed with "Cannot insert the value NULL into column
'LastUpdated'". Add DEFAULT SYSUTCDATETIME() so the DB stamps the load
time when ADF omits the columns.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cd0f545c-0375-4407-b253-ef25594f5cbe

📥 Commits

Reviewing files that changed from the base of the PR and between 34d72e3 and af0231d.

📒 Files selected for processing (1)
  • datamart/Tables/EmployeeAccrualBalances.sql

📝 Walkthrough

Walkthrough

The dbo.EmployeeAccrualBalances table definition is updated to add named default constraints (DF_EmployeeAccrualBalances_LoadDate and DF_EmployeeAccrualBalances_LastUpdated) on the LoadDate and LastUpdated columns, both defaulting to sysutcdatetime().

Changes

Default UTC Timestamp Constraints

Layer / File(s) Summary
LoadDate and LastUpdated default constraints
datamart/Tables/EmployeeAccrualBalances.sql
LoadDate and LastUpdated column definitions now include named default constraints (DF_EmployeeAccrualBalances_LoadDate, DF_EmployeeAccrualBalances_LastUpdated) binding sysutcdatetime() as the default value for each column.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐇 Tick-tock, the clock now knows,
UTC time wherever it goes,
LoadDate and LastUpdated stand tall,
With sysutcdatetime() for all!
No more blanks — timestamps hooray!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main change: adding default UTC timestamps to the LastUpdated and LoadDate columns on the EmployeeAccrualBalances table.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rpm/accruals-lastupdated-default

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant