Skip to content

Added row-level checks for geometry columns#636

Merged
mwojtyczka merged 6 commits into
mainfrom
geo_scale_checks
Dec 12, 2025
Merged

Added row-level checks for geometry columns#636
mwojtyczka merged 6 commits into
mainfrom
geo_scale_checks

Conversation

@ghanse

@ghanse ghanse commented Oct 22, 2025

Copy link
Copy Markdown
Collaborator

Changes

Added row-level checks for geometry columns (e.g. WKT):

  • is_area_less_than
  • is_area_greater_than
  • is_area_equal_to
  • is_area_not_equal_to
  • is_num_points_less_than
  • is_num_points_greater_than
  • is_num_points_equal_to
  • is_num_points_not_equal_to

Linked issues

Resolves #605

Tests

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

@github-actions

github-actions Bot commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

✅ 491/491 passed, 1 flaky, 41 skipped, 3h14m27s total

Flaky tests:

  • 🤪 test_e2e_workflow_serverless (9m35.427s)

Running from acceptance #3401

@github-actions

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

@codecov

codecov Bot commented Oct 24, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.09910% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.40%. Comparing base (c5d5f8e) to head (34cab01).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/databricks/labs/dqx/pii/pii_detection_funcs.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #636      +/-   ##
==========================================
+ Coverage   88.75%   90.40%   +1.65%     
==========================================
  Files          64       64              
  Lines        6306     6350      +44     
==========================================
+ Hits         5597     5741     +144     
+ Misses        709      609     -100     

☔ 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.

@tdikland

Copy link
Copy Markdown
Contributor

Nice work!

I was wondering, what use cases would you solve with the area_eq and area_not_eq checks? Also, for the user it is unclear what kind of area we are talking about (for general geom the coords are in meters and you would typically do it in m^2 in the grid, but for geog the user might be expecting that the lat/lon coords would lead to the area on earth in m^2)

@ghanse

ghanse commented Oct 30, 2025

Copy link
Copy Markdown
Collaborator Author

Nice work!

I was wondering, what use cases would you solve with the area_eq and area_not_eq checks? Also, for the user it is unclear what kind of area we are talking about (for general geom the coords are in meters and you would typically do it in m^2 in the grid, but for geog the user might be expecting that the lat/lon coords would lead to the area on earth in m^2)

has_area_equal_to could be used to ensure cells from tessellation or buffered geometries have a specific size. Some applications will create buffered areas around points of interest with a default radius.

Do you think we should have separate check methods for geometry and geography? The geometry checks could allow the user to set an SRID to control the area units of measure. I believe st_area should return m^2 for geography types.

Copilot AI 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.

Pull Request Overview

This PR adds eight new geometry validation functions for data quality checks on spatial data, covering area and point count validations with standard comparison operators.

  • Implements area validation functions (has_area_less_than, has_area_greater_than, has_area_equal_to, has_area_not_equal_to)
  • Implements point count validation functions (has_num_points_less_than, has_num_points_greater_than, has_num_points_equal_to, has_num_points_not_equal_to)
  • Adds comprehensive test coverage including unit tests, integration tests, and performance benchmarks

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/databricks/labs/dqx/geo/check_funcs.py Implements the 8 new geometry check functions and a helper function for spatial comparisons
tests/integration/test_row_checks_geo.py Adds integration tests for all new geometry check functions
tests/perf/test_apply_checks.py Adds performance benchmark tests for the new functions
tests/perf/.benchmarks/baseline.json Records baseline performance metrics for the new functions
tests/resources/all_row_geo_checks.yaml Adds YAML configuration examples for the new checks
tests/integration/test_apply_checks.py Integrates the new check functions into existing test suite
src/databricks/labs/dqx/llm/resources/yaml_checks_examples.yml Adds YAML examples for LLM resources
docs/dqx/docs/reference/quality_checks.mdx Documents the new functions in the quality checks reference
docs/dqx/docs/reference/benchmarks.mdx Updates benchmark documentation with new function metrics

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +413 to +419
limit: 100.0
- criticality: error
check:
function: has_area_less_than
arguments:
column: polygon_geom
limit: 0.1

Copilot AI Oct 31, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent parameter naming: has_area_greater_than and has_area_less_than use limit while has_area_equal_to and has_area_not_equal_to use value. All area functions should use the same parameter name for consistency.

Suggested change
limit: 100.0
- criticality: error
check:
function: has_area_less_than
arguments:
column: polygon_geom
limit: 0.1
value: 100.0
- criticality: error
check:
function: has_area_less_than
arguments:
column: polygon_geom
value: 0.1

Copilot uses AI. Check for mistakes.
Comment on lines +413 to +419
limit: 100.0
- criticality: error
check:
function: has_area_less_than
arguments:
column: polygon_geom
limit: 0.1

Copilot AI Oct 31, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent parameter naming: has_area_greater_than and has_area_less_than use limit while has_area_equal_to and has_area_not_equal_to use value. All area functions should use the same parameter name for consistency.

Suggested change
limit: 100.0
- criticality: error
check:
function: has_area_less_than
arguments:
column: polygon_geom
limit: 0.1
value: 100.0
- criticality: error
check:
function: has_area_less_than
arguments:
column: polygon_geom
value: 0.1

Copilot uses AI. Check for mistakes.
function: has_area_greater_than
arguments:
column: polygon_geom
limit: 100.0

Copilot AI Oct 31, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent parameter naming in documentation: has_area_greater_than and has_area_less_than use limit while has_area_equal_to and has_area_not_equal_to use value. This should match the actual API which uses value for all functions.

Copilot uses AI. Check for mistakes.
function: has_area_less_than
arguments:
column: polygon_geom
limit: 0.1

Copilot AI Oct 31, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent parameter naming in documentation: has_area_greater_than and has_area_less_than use limit while has_area_equal_to and has_area_not_equal_to use value. This should match the actual API which uses value for all functions.

Copilot uses AI. Check for mistakes.
Comment thread docs/dqx/docs/reference/quality_checks.mdx Outdated
Comment thread docs/dqx/docs/reference/quality_checks.mdx Outdated
Comment thread src/databricks/labs/dqx/geo/check_funcs.py Outdated
Comment thread src/databricks/labs/dqx/geo/check_funcs.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.

LGTM

@mwojtyczka mwojtyczka mentioned this pull request Dec 19, 2025
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.

[FEATURE]: Check for complex/large geometries

4 participants