Skip to content

refactor(data): exhaustively classify numeric expression functions - #2183

Closed
giswqs wants to merge 1 commit into
mainfrom
sweep/data-quality-2026-11-15
Closed

giswqs wants to merge 1 commit into
mainfrom
sweep/data-quality-2026-11-15

Conversation

@giswqs

@giswqs giswqs commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Summary

Make number_func an exhaustive match over the expression-function vocabulary. Adding a function now requires an explicit decision about numeric arguments before the parser compiles, preserving the date-comparison guard instead of silently classifying a new numeric function as text. Existing function behavior is unchanged.

Handles the deferred release-quality point: #1325 (comment)

Testing

  • rustfmt --edition 2024 crates/data/src/query.rs and git diff --check passed.
  • cargo check -p rustgis-data passed; full workspace tests are left to CI.
  • Local GDAL version: GDAL 3.13.3 (Iowa City).

UI evidence

No visible UI change.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

number_func now uses an exhaustive match to classify each Func variant. The numeric-function set is unchanged. All other variants return false.

Changes: Function Numeric Classification

Layer / File(s) Summary
Exhaustive function classification
crates/data/src/query.rs
number_func explicitly classifies every Func variant as numeric or nonnumeric.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Possibly related issues

  • Issue 1240: The change makes number_func exhaustive, which aligns with the issue’s goal of keeping function classification synchronized with Func. It does not complete the requested function catalog.

Suggested reviewers: mavrick-f

Merge Risk: Minimal · up to 8f372

This refactor makes function classification explicit at compile time and leaves existing behavior unchanged. No concrete merge risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the refactor and the affected area: making numeric expression function classification exhaustive in the data crate. The raw summary confirms number_func in crates/data/src/query.rs…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description supplies a Summary explaining the exhaustive match over the expression-function vocabulary and why it matters, plus a Testing section listing rustfmt, git diff --check, and cargo check…
Full details: Title check

Explanation

The title names the refactor and the affected area: making numeric expression function classification exhaustive in the data crate. The raw summary confirms number_func in crates/data/src/query.rs now matches every Func variant explicitly instead of relying on a matches! fallback to false. The title is specific and matches the main change.

Full details: Description check

Explanation

The description supplies a Summary explaining the exhaustive match over the expression-function vocabulary and why it matters, plus a Testing section listing rustfmt, git diff --check, and cargo check results. The UI evidence section states no visible UI change, which matches the template's allowed line. The Related issue section is missing its value: the author links a PR discussion (PR #1325 discussion) in the Summary rather than in a Related issue entry. The description is mostly complete, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each function name,
The numeric set stays the same.
Each variant gets a stated place,
No hidden case can leave a trace.
Hop by hop, the match is complete.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: f7b64cdd-9351-45f2-80b7-b3ce16731754
Commits

Reviewing files that changed from the base of the PR and between ce40749 and 8f372c6.

Files selected for processing: 1

  • crates/data/src/query.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 0 remain after this review.

Comment thread crates/data/src/query.rs
| Func::ColorRgb
| Func::ColorRgba => true,
// Keep this exhaustive: a new function must decide whether dates are valid arguments.
// text_or_date also uses this distinction to reject numeric/date comparisons.

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.

Confidence: medium. The comment says text_or_date "uses this distinction", but it doesn't fully. At query.rs:1042, text_or_date treats any function that is not in number_func's true arm as text, then carves out a second hand-written list: Func::Length | Func::Pi | Func::Area | Func::Perimeter | Func::LineLength. The exhaustive match only forces a decision in number_func, so a new function that returns a number but is placed in the false arm (as Length, Pi, Area etc. already are) is silently classified as text by text_or_date unless someone also remembers that second list. That is the same silent-misclassification the PR says it prevents.

Behaviour is unchanged by this PR, so this is not a regression. It is a gap the comment overstates. Options: make text_or_date an exhaustive match as well, or at least say in the comment that the exclusion list at line 1042 must also be updated for a new numeric-returning function.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • None introduced. I checked that the new exhaustive match in number_func (crates/data/src/query.rs:234) lists the same 17 true functions as the old matches!. The 17 false arms plus those 17 make 34, which matches the Func enum (lines 159–195), so the arms cover every variant with nothing extra. Existing behaviour is unchanged. Confidence: high. I could not run cargo check here, so compilation rests on the author's note and CI.

Security

  • None found. The change is pure classification logic with no input handling.

Performance

  • None. The function is a match over a Copy enum.

Quality

  • Posted one inline comment (confidence: medium) on the text_or_date comment at query.rs:254. text_or_date (query.rs:1042) treats any function outside the number_func true arm as text, then excludes Length | Pi | Area | Perimeter | LineLength with a hand-written list. The exhaustive match only forces a decision in number_func. A new numeric-returning function placed in the false arm would be silently classified as text, which is the failure the PR says it prevents. The comment's claim that text_or_date "also uses this distinction" is therefore overstated. Behaviour is unchanged, so this is a gap rather than a regression.
  • Nit (confidence: high, grouped): the number_func doc comment ("works on numbers, so it gives null for a date") doesn't match the false arm. Length, Pi, Area, Perimeter and LineLength return numbers but are false here. The doc should say the function is not a date-valid numeric function, not that it yields text.

AGENTS.md

  • Compliant. The change is a refactor with no crash paths, silent data loss, or saved-format change, so no schema run is needed. No new test was added. AGENTS.md allows the missing extra test for code that works, and the existing query tests cover the date guard.

Prior reviews

  • No prior review threads exist on this PR, so no earlier concerns were skipped.

Change size

Compared: the whole PR against main (merge base ce40749 to PR head 8f372c6).

Measure Value
Files changed 1 (added 0, modified 1, removed 0, renamed 0)
Size before 74.9 KB
Size after 75.4 KB
Total size change +510 B
Path Before After Change
crates/data/src/query.rs 74.9 KB 75.4 KB +510 B

@giswqs

giswqs commented Nov 15, 2026

Copy link
Copy Markdown
Member Author

Superseded by the combined data release-quality PR #2197.

@giswqs giswqs closed this Nov 15, 2026
@giswqs
giswqs deleted the sweep/data-quality-2026-11-15 branch December 1, 2026 22:25
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.

1 participant