Skip to content

Explain: let plugin drivers return raw explain output parsed by @tabularis/explain (SQL Server SHOWPLAN) #2

Description

@debba

Context

For built-in drivers, explain_query returns ExplainQueryOutput::Raw { raw: RawExplainOutput } — a payload plus a format tag — and the parsing lives in the @tabularis/explain TypeScript package (parseRawExplain).

For plugin drivers, the host wraps the JSON-RPC result as ExplainQueryOutput::Plan { plan } and passes it to the frontend untouched (src-tauri/src/plugins/driver.rs). A plugin must therefore ship its own parser and emit the visual-plan model directly: the SQL Server plugin currently parses SHOWPLAN_XML in Rust (src/driver/showplan.rs) and returns the parsed tree.

Goal

Make plugin explain output flow through @tabularis/explain the same way built-in drivers do:

  1. Add the SQL Server SHOWPLAN XML parser to @tabularis/explain (a complete implementation already exists in PR feat(sqlserver): add built-in SQL Server driver tabularis#560: packages/explain/src/parsers/sqlserver.ts + tests, format tag sqlserver-showplan-xml).
  2. Extend the plugin protocol so a plugin's explain_query can return a RawExplainOutput-shaped result ({ engine, format, payload, original_query }) that the host forwards as ExplainQueryOutput::Raw, letting parseRawExplain handle it in the frontend. Plugins that already return a parsed plan keep working (Plan pass-through stays the fallback).
  3. Switch the SQL Server plugin to return the raw XML and drop its in-process parser.

Why

  • One parser, one place: plan-rendering fixes and new metrics land in @tabularis/explain without re-releasing plugins.
  • explain.tabularis.dev consumes @tabularis/explain, so it gains direct SQL Server compatibility — paste a SHOWPLAN_XML document and get the visual plan, with no plugin involved.
  • Keeps plugins thin: they hand over what the engine produced, tagged with its format, exactly like built-in drivers.

Notes

  • The parser from PR feat(sqlserver): add built-in SQL Server driver tabularis#560 sums per-thread ActualRows/ActualExecutions and takes the max ActualElapsedms from RunTimeInformation, so STATISTICS XML (Analyze) is covered too.
  • Registry/versioning: the manifest could declare an explain_format (or the result itself is self-describing via the format tag) so older hosts keep treating plugin results as pre-parsed plans.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions