Skip to content

Conversation

sjohansson
Copy link
Contributor

add initial version of circular relationship testing for testing

add initial version of circular relationship testing for testing
@sjohansson sjohansson requested review from RoelantVos and Copilot May 20, 2025 11:30
@sjohansson sjohansson linked an issue May 20, 2025 that may be closed by this pull request
1 task
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements an initial version of circular relationship detection for batch hierarchies in the stored procedure. It adds a recursive CTE to traverse the DAG, performs cycle detection by verifying that the new relationship does not introduce a cycle, and logs an error when a cycle is found.

Comment on lines +162 to +163
DROP TABLE IF EXISTS #DagViolation;
GOTO EndOfProcedureFailure;
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using GOTO for error handling can reduce the clarity and maintainability of the procedure. Consider refactoring the error handling to rely solely on the TRY/CATCH structure instead of branching with GOTO.

Suggested change
DROP TABLE IF EXISTS #DagViolation;
GOTO EndOfProcedureFailure;
SET @SuccessIndicator = 'N';
DROP TABLE IF EXISTS #DagViolation;
THROW 50001, @LogMessage, 1;

Copilot uses AI. Check for mistakes.

IF @CheckDag = 'Y'
BEGIN
PRINT('There should be some clever SQL added here to warn of circular relations...')
;WITH Ancestors AS (
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful to include a comment explaining the recursive CTE's logic and how it retrieves the chain of ancestors for cycle detection.

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

@RoelantVos RoelantVos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Stefan!

@RoelantVos RoelantVos merged commit e2cb597 into main Jun 3, 2025
4 checks passed
@RoelantVos RoelantVos deleted the 33-add-batch-hierarchy-circular-reference-checks branch June 7, 2025 08:32
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.

Add batch hierarchy circular reference checks

2 participants