Hi @Siddharth Chakraborty Yes, it's possible to create a custom data quality (DQ) rule in Microsoft Purview to validate hierarchical relationships across two different tables, though it requires a few workarounds since Purview’s out-of-the-box DQ capabilities are primarily column-level and table-level.
In your scenario, since TableA → TableB has a one-to-many relationship and the rule depends on cross-table logic, you can approach it as follows:
- Use a Custom SQL Rule: If your data source supports it (like Azure SQL DB, Synapse, etc.), you can define a custom SQL query in your DQ rule that joins TableA and TableB based on the relationship and checks the logic. For example:
This query identifies the records violating your logic. In Purview, you can configure a custom DQ rule with this logic and define it as a "Row-level" validation.SELECT B.* FROM TableA A JOIN TableB B ON A.Key = B.ForeignKey WHERE A.Field1 = 'PlantABC' AND B.Field2 NOT IN ('PlantA', 'PlantB', 'PlantC')
- Custom Rule in DQ Rule Set: Go to the Data Map → Rules → Add Rule Set → Custom Rule → SQL Rule (or Spark rule if using a Spark-based scan). Include the logic above and assign it to the dataset.
- Validation: After applying the rule, run a scan with DQ enabled to evaluate the quality. The DQ results will show how many records pass/fail the rule.
I hope this information helps. Please do let us know if you have any further queries.
Kindly consider upvoting the comment if the information provided is helpful. This can assist other community members in resolving similar issues.