fix #33#43
Conversation
There was a problem hiding this comment.
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.
| DROP TABLE IF EXISTS #DagViolation; | ||
| GOTO EndOfProcedureFailure; |
There was a problem hiding this comment.
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.
| DROP TABLE IF EXISTS #DagViolation; | |
| GOTO EndOfProcedureFailure; | |
| SET @SuccessIndicator = 'N'; | |
| DROP TABLE IF EXISTS #DagViolation; | |
| THROW 50001, @LogMessage, 1; |
| IF @CheckDag = 'Y' | ||
| BEGIN | ||
| PRINT('There should be some clever SQL added here to warn of circular relations...') | ||
| ;WITH Ancestors AS ( |
There was a problem hiding this comment.
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.
add initial version of circular relationship testing for testing