Improve postprocessor extensibility

Open
#39,419 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp

Research direction

Read RelationalQueryTranslationPostprocessor.cs and compare the SQL Server and SQLite postprocessors named in the issue to trace the current phase ordering and provider overrides. Then inspect related tests for query postprocessing, including split queries and shaper expressions. Done means supported phase hooks preserve common finalization and verification ordering, existing provider behavior and Process overrides are covered, and provider API docs describe each phase's invariants.

Written by the indexing model from the issue text.

Description

area-query needs-design

Providers can already replace IQueryTranslationPostprocessorFactory, derive from QueryTranslationPostprocessor or RelationalQueryTranslationPostprocessor, and override Process. The relational implementation also exposes ProcessTypeMappings and Prune. The remaining problem is fine-grained customization of the common postprocessing sequence without copying it.

RelationalQueryTranslationPostprocessor.Process directly orchestrates projection application, pruning, alias postprocessing, simplification, and value-converter compensation. A provider can add passes before or after base.Process, but cannot independently override or insert work between most of those phases.

This also creates an ordering problem for finalization and validation. The relational implementation contains a TODO noting that alias postprocessing and the subsequent verification should run after all visitors, including provider-specific ones. SQL Server and SQLite currently run additional transformations after base.Process, so common finalization is not necessarily the last stage.

Current implementation:

Describe the solution you'd like

Provide supported, narrowly scoped provider extension points within the postprocessing pipeline, keeping required common behavior and ordering in the base implementation.

In particular:

  • Allow providers to specialize appropriate common phases without duplicating Process.
  • Provide an explicit place for provider-specific transformations relative to projection application, pruning, simplification, and finalization.
  • Define which common finalization/verification steps must run after provider transformations and ensure the supported orchestration honors that ordering.
  • Document the tree shape and invariants at each supported boundary, including type mappings, projection bindings, aliases, and select-expression mutability.

Prefer protected virtual phase methods and reuse of the existing factory/dependency model. The precise API and division into phases need design; this issue does not prescribe a general-purpose pass scheduler or plugin registry.

Acceptance criteria
  • A derived provider postprocessor can customize a supported intermediate phase without reproducing the base processing sequence.
  • Existing ProcessTypeMappings and Prune specialization remains supported.
  • Providers have a supported path to perform their transformations before the common finalization/verification steps that must observe the final tree.
  • Tests establish ordering of common and provider phases and exercise provider-created or modified SQL nodes.
  • Coverage includes shaper-side query expressions where relevant, including split queries; transformations preserve projection-binding and alias consistency.
  • Existing SQL Server and SQLite postprocessing behavior is preserved, with intentional ordering changes explicitly tested.
  • Document compatibility for existing Process overrides rather than silently bypassing them.
  • Provider-facing API documentation explains supported phases and their invariants. Newly exposed provider APIs follow the repository's provider API conventions.
Scope and related work
  • This is a database-provider extension surface, not application interception. #19748 does not replace this work.
  • #32979 concerns correct query/shaper visitation and #32980 concerns projection-binding references. This work must respect those constraints but does not require resolving those architectural issues.
  • Visitor consolidation and traversal-count optimization are separate work. Phase extensibility should not unnecessarily prevent future consolidation.
Dominant language
C#
Stars
14.8k
Forks
3.5k
Avg merge
3d 7h
Merged PRs (30d)
182

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/efcore

All issues in dotnet/efcore

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.