Skip to content

Allow custom check messages#1092

Open
ghanse wants to merge 17 commits intomainfrom
ghanse/issue-958-custom-check-messages
Open

Allow custom check messages#1092
ghanse wants to merge 17 commits intomainfrom
ghanse/issue-958-custom-check-messages

Conversation

@ghanse
Copy link
Copy Markdown
Collaborator

@ghanse ghanse commented Mar 20, 2026

Changes

Add an optional message callable parameter to DQRule, DQRowRule, DQDatasetRule, and DQForEachColRule that allows users to define custom check failure messages. The callable receives rule context (rule_name, check_func_name, check_func_args, column_value) and returns a Spark Column expression, enabling dynamic messages that can include column values.

When message is None (the default), the existing auto-generated message behavior is preserved. When provided, the custom message replaces the default message for failed rows while maintaining null/non-null semantics for passing rows.

Linked issues

Resolves #958

Tests

  • manually tested
  • added unit tests
  • added integration tests

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 20, 2026

✅ 738/738 passed, 41 skipped, 4h43m32s total

Running from acceptance #4562

@ghanse ghanse changed the title feat: add message callable to DQRule for custom check messages Allow custom check messages Mar 21, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.64%. Comparing base (7bb1023) to head (4560ac6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/databricks/labs/dqx/manager.py 66.66% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (7bb1023) and HEAD (4560ac6). Click for more details.

HEAD has 17 uploads less than BASE
Flag BASE (7bb1023) HEAD (4560ac6)
unit 4 1
anomaly 4 1
anomaly-serverless 4 1
integration-serverless 4 0
integration 4 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1092       +/-   ##
===========================================
- Coverage   92.11%   72.64%   -19.47%     
===========================================
  Files         101      101               
  Lines        9546     9557       +11     
===========================================
- Hits         8793     6943     -1850     
- Misses        753     2614     +1861     
Flag Coverage Δ
anomaly 53.56% <72.72%> (+0.02%) ⬆️
anomaly-serverless 53.58% <72.72%> (+0.02%) ⬆️
integration ?
integration-serverless ?
unit 55.91% <81.81%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

mwojtyczka and others added 5 commits April 28, 2026 09:58
…eholders

The custom-message field is renamed to message_expr and now accepts either a
Spark SQL expression string or a Spark Column object. The expression is
evaluated as-is — DQX no longer substitutes {rule_name}, {check_func_name}, or
{column_value} placeholders. Callers reference columns and identifiers directly
inside the expression.

- DQRule / DQForEachColRule: rename message -> message_expr (str | Column | None)
- to_dict serialises message_expr only when it is a string (Column is in-process)
- DQRuleManager._build_message_col simplified: F.expr(str) or use Column directly
- checks_serializer: read message_expr key from metadata, pass to constructors
- Unit tests rewritten for the new attribute name and Column variant
- Integration tests rewritten without placeholders; the existing
  test_apply_checks_without_custom_message_unchanged is dropped (the Engine's
  no-message default path is already covered by surrounding tests)
- Docs (quality_checks.mdx) rewritten to drop the placeholder section, add a
  Column-based Python example, and annotate each example with the rendered
  message string

Co-authored-by: Isaac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-changes Changes required after review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Enable custom message for checks

2 participants