Skip to content

feat: add is_valid_email row check function#1158

Merged
mwojtyczka merged 12 commits into
databrickslabs:mainfrom
aarushisingh04:feat/is-valid-email
Jun 3, 2026
Merged

feat: add is_valid_email row check function#1158
mwojtyczka merged 12 commits into
databrickslabs:mainfrom
aarushisingh04:feat/is-valid-email

Conversation

@aarushisingh04

Copy link
Copy Markdown
Contributor

changes

added a new is_valid_email row-level check function that validates email addresses following a pragmatic subset of RFC 5321/5322.

implementation:

  • adds a ReDoS-safe EMAIL_ADDRESS pattern to the DQPattern registry.
  • behaves identically to is_valid_ipv4_address by ignoring null values (no violation reported).
  • can be used in programmatic DQRowRule / DQForEachColRule creation and declarative YAML metadata setups (function: is_valid_email).

linked issues

resolves #1156

tests

  • manually tested
  • added unit tests
  • added integration tests
  • added end-to-end tests
  • added performance tests

documentation and demos

  • added/updated demos
  • added/updated docs
  • added/updated agent skills

@aarushisingh04 aarushisingh04 requested a review from a team as a code owner May 5, 2026 20:00
@aarushisingh04 aarushisingh04 requested review from mwojtyczka and removed request for a team May 5, 2026 20:00
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

All commits in PR should be signed ('git commit -S ...'). See https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

@aarushisingh04 aarushisingh04 force-pushed the feat/is-valid-email branch from adeee39 to c1234b5 Compare May 5, 2026 20:10
@aarushisingh04 aarushisingh04 force-pushed the feat/is-valid-email branch from 7da2c71 to 5f57700 Compare May 5, 2026 20:12
@ghanse ghanse self-requested a review May 5, 2026 21:16
@ghanse ghanse added the under-review This PR is currently being reviewed by one of DQX maintainers. label May 5, 2026
ghanse
ghanse previously requested changes May 5, 2026

@ghanse ghanse left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good overall. You will need to sign your commits (see the contributor docs for more info).

Can you add documentation for this function to /docs/reference/quality_checks.mdx? You will need to update the row-level checks table, Python examples, and YAML examples.

Comment thread tests/unit/test_row_checks.py Outdated
@aarushisingh04 aarushisingh04 force-pushed the feat/is-valid-email branch from e33c783 to 72ddac9 Compare May 6, 2026 08:18
@aarushisingh04

Copy link
Copy Markdown
Contributor Author

@ghanse thanks for the review, i have addressed all of the above mentioned points

@mwojtyczka mwojtyczka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Solid contribution overall — well-tested, well-documented, and follows the existing _matches_pattern shape. Posting 6 inline comments (1 correctness gap, several polish items). One additional ask below.

Add a performance test

Regex-based row checks like this can have non-obvious cost on adversarial inputs. Could you add a perf test under tests/perf/ benchmarking is_valid_email against a representative mix (valid dot-atom, quoted-local, IP-literal, long-but-rejected strings) so we have a baseline before merge? The existing IPv4/IPv6 perf cases are a good template.

Comment thread src/databricks/labs/dqx/check_funcs.py
Comment thread src/databricks/labs/dqx/check_funcs.py
# Domain: LDH hostname with alphabetic TLD, or IP-literal
rf"(?:"
rf"(?:{_EMAIL_DOMAIN_LABEL}\.)+[A-Za-z]{{2,63}}"
rf"|\[(?:{_IPV4_OCTET}(?:\.{_IPV4_OCTET}){{3}}|IPv6:[A-Fa-f0-9:]+)\]"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(Cosmetic) Captured-group count grows.

_IPV4_OCTET = r"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)" is a capturing group. Each reuse here adds 4 more capture groups beyond what's needed (the existing IPV4_ADDRESS does the same). No correctness impact, but switching _IPV4_OCTET to non-capturing (?:…) once at its definition would clean this up across all callers. Optional; can be a follow-up.

Comment thread src/databricks/labs/dqx/check_funcs.py Outdated
Comment thread src/databricks/labs/dqx/check_funcs.py
Comment thread tests/integration/test_row_checks.py Outdated

@mwojtyczka mwojtyczka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for your contribution. The PR is generally close to be ready. I left some comments. Please add also one performance test and add the check here: https://github.com/databrickslabs/dqx/blob/main/tests/resources/all_row_checks.yaml

@aarushisingh04

Copy link
Copy Markdown
Contributor Author

@ghanse thanks for the ongoing fixes. to avoid potential duplication of efforts, shall i address the comments above that are to be resolved? i am ready to do it, please let me know if you have a different plan.

@ghanse

ghanse commented May 12, 2026

Copy link
Copy Markdown
Collaborator

@ghanse thanks for the ongoing fixes. to avoid potential duplication of efforts, shall i address the comments above that are to be resolved? i am ready to do it, please let me know if you have a different plan.

I think this looks good now. Made a few small changes to the pattern and added a few test cases.

@CLAassistant

CLAassistant commented Jun 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread tests/perf/test_apply_checks.py Outdated
Comment thread tests/perf/test_apply_checks.py Outdated
Comment thread tests/perf/conftest.py Outdated
@mwojtyczka

mwojtyczka commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

@ghanse @aarushisingh04 perf tests have some small issues, left comments. Otherwise LGTM

@mwojtyczka mwojtyczka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@mwojtyczka mwojtyczka merged commit 99e47bd into databrickslabs:main Jun 3, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

under-review This PR is currently being reviewed by one of DQX maintainers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add email validation check function

4 participants