Skip to content

refactor(data): share export query compilation and matching - #2432

Merged
Mavrick-F merged 1 commit into
opengeos:mainfrom
Mavrick-F:t3/export-query-adoption
Nov 19, 2026
Merged

Mavrick-F merged 1 commit into
opengeos:mainfrom
Mavrick-F:t3/export-query-adoption

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Exports now compile definition queries through data::rows::Query, completing export adoption of the shared query seam introduced in #2421. Its new chunk matcher delegates to the existing query::eval_in_chunk, preserving source-wide @row_number semantics.

whole-data / chunk export → rows::Query → existing query evaluator

Export callers retain whole-source traversal, writer replay counters, borrowed/owned row handling, progress, cancellation and notice delivery. Blank queries remain absent; unreadable queries retain all rows and report the parser error once. Format-loss counts still use kept rows.

This reaches layer export and Data Interop's file and text paths through their existing shared calls, including desktop, browser downloads, CLI, Python and phone callers. Command dispatch, ribbon, shortcuts, search, Assistant/MCP and plugins retain their existing interfaces. No saved fields or Undo state change; files can be reopened as before.

Testing

  • Existing data export tests, including chunk row numbering across a fully excluded chunk and GeoPackage replay.
  • Existing engine write_notices tests, including export fallback and Data Interop text/explicit-format paths.
  • Changed-crate Clippy, strict wasm check, formatting and full fork CI.

UI evidence

No visible UI change.

Related issue

Part of #2402. Follows #2417 and #2421.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed filtered exports across multiple chunks so row-number filters continue to use source-wide row positions, including rows excluded from earlier chunks.
    • Export filters are now compiled against the dataset before being applied, helping ensure consistent filtering during streamed exports.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Export definition queries are now compiled as rows::Query and applied to chunk rows with source-wide offsets. The export test now constructs its row-number filter through Query::compile.

Changes: Definition-query export filtering

Layer / File(s) Summary
Chunk-aware query matching
crates/data/src/rows.rs
Query::matches_in_chunk evaluates a query against a chunk row using the supplied offset for source rows before that chunk.
Export query integration
crates/data/src/export.rs, crates/data/src/export/tests.rs
Export compiles the optional query as Query, passes it through the chunk-writing helpers, and uses matches_in_chunk to filter rows. The streamed-export test compiles its row-number filter with Query::compile.

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

Change: Refactor · Severity of issue fixed: Medium

Possibly related issues

Possibly related PRs

  • opengeos/RustGIS#2417: This PR changes the query compilation and matching used by the export filtering introduced in #2417.
  • opengeos/RustGIS#2421: This PR routes export definition queries through the shared query path that #2421 introduced.

Suggested reviewers: flight1973, giswqs

Merge Risk: Minimal · up to 60739

This refactor routes export definition queries through the shared query type without a visible behavior change. No concrete merge risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the refactor in the data crate: export query compilation and matching now go through the shared rows::Query seam. The changeset matches this: export.rs switches to rows::Query, rows.rs…
Description check Passed The description follows the template sections: Summary, Testing, UI evidence, and Related issue. The Summary explains the change and its scope, and it names the shared query path and the semantics it …
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.
Full details: Title check

Explanation

The title names the refactor in the data crate: export query compilation and matching now go through the shared rows::Query seam. The changeset matches this: export.rs switches to rows::Query, rows.rs adds matches_in_chunk, and tests use Query::compile. The title is specific and conventional, and it covers the main change.

Full details: Description check

Explanation

The description follows the template sections: Summary, Testing, UI evidence, and Related issue. The Summary explains the change and its scope, and it names the shared query path and the semantics it preserves. Testing lists the existing test suites and CI checks run. UI evidence states no visible UI change, as the template requires. The Related issue section cites #2402, #2417 and #2421. The template's placeholder comments are removed and replaced with content. The description does not add new tests for matches_in_chunk, which is a minor gap, but the section is otherwise complete.

Finishing Touches

Generate unit tests (beta)

  • 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 row in line,
With offsets kept across the span.
The export follows the query’s sign,
And filters chunks as rows began.
The test now speaks the same command.

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: 299c4bc6-4842-4760-92c4-722265b52c7d
Commits

Reviewing files that changed from the base of the PR and between 4396ab3 and 607397a.

Files selected for processing: 3

  • crates/data/src/export.rs
  • crates/data/src/export/tests.rs
  • crates/data/src/rows.rs

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

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs: None found. I compared the new Query::compile path against the old parse_fields path in export_query. Blank and whitespace-only queries still yield no filter with no report. Unreadable queries still keep all rows and carry the parser error. matches_in_chunk calls eval_in_chunk with the same default Env the old code used, so @row_number semantics are unchanged. Confidence: high (~90%).

Security: None found. No new input handling beyond the existing parser call, and no unwrap, panic, or unsafe code added in non-test code.

Performance: None found. retain_matches keeps its per-row progress step and cancel check, and the extra Query wrapper adds no allocation per row.

Quality:

  • crates/data/src/export.rs:207-209 (low confidence, nit): filter_dataset binds the result of export_query to expr, but that value is now a Query, so the name is misleading. Suggested rename:
    let (query, mut report) = export_query(definition_query, ds);
    if let Some(query) = query {
        report.filtered = retain_matches(ds, &query, 0, true)?;
    }
    This is a quality point, so it can wait for the release quality pass.
  • crates/data/src/rows.rs:15-35 (low confidence, coverage note): Query::compile, is_filtered and matches_in_chunk have no direct unit tests in rows.rs. The blank and unreadable-query behaviour is reached only through export callers. I searched crates/data/src/export/tests.rs and found no parse_error or blank-query assertion there. The PR says engine write_notices tests cover the fallback, but I did not check that from this diff. This is a test-coverage gap rather than a bug.

AGENTS.md: No violations found in the changed files. The change adds no saved fields, so cargo xtask schema is not needed. There is no new timer, command, or background path. No platform-specific code is touched, so wasm is unaffected. The PR description covers the surfaces reached.

Prior reviews: None on this PR, so no earlier concerns were left alone. No inline comments were posted, since nothing rises above a nit.

Change size

Compared: the whole PR against main (merge base 26f4d2b to PR head 607397a).

Measure Value
Files changed 3 (added 0, modified 3, removed 0, renamed 0)
Size before 51.0 KB (52,191 B)
Size after 51.2 KB (52,461 B)
Total size change +270 B
Path Before After Change
crates/data/src/rows.rs 1.3 KB 1.7 KB +367 B
crates/data/src/export.rs 17.8 KB 17.7 KB -98 B
crates/data/src/export/tests.rs 31.9 KB 31.9 KB +1 B

@Mavrick-F

Copy link
Copy Markdown
Member Author

The existing export_features_respects_the_definition_query test checks valid, absent and unreadable queries across resident export, streamed whole-data export and streamed background chunk export. It asserts the written features, no query notice for an absent query, and exactly one notice retaining the parser error for an unreadable query. Those cases passed among the 14 engine write-notice tests on this head, along with the data suite and full fork CI. The chunk regression also reaches the shared matcher with a fully excluded initial chunk.

The expr variable rename and additional direct wrapper unit cases are left for the release quality pass.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2432/
Web app https://preview.rustgis.app/pr-2432/app/
Commit 607397a

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

@Mavrick-F
Mavrick-F added this pull request to the merge queue Nov 19, 2026
Merged via the queue into opengeos:main with commit 0cc1eb2 Nov 19, 2026
24 checks passed
@Mavrick-F
Mavrick-F deleted the t3/export-query-adoption branch November 19, 2026 01:22
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