Skip to content

Derived Table support for @perspective-dev/viewer - #3249

Open
texodus wants to merge 2 commits into
masterfrom
new-view-ui
Open

texodus wants to merge 2 commits into
masterfrom
new-view-ui

Conversation

@texodus

@texodus texodus commented Oct 8, 2026

Copy link
Copy Markdown
Member

This PR build on #3246 by adding support for deriving client.table(view) in the <perspective-viewer> UI, ViewerConfig and WorkspaceConfig.

Derived tables in perspective-viewer

  • restoreWorkspace() / saveWorkspace() have a new a top-level derived_tables map. Each entry is the table its source View reads plus that view's config. Entries may chain through other derived tables and are built parent-first. The key follows the panels update rule: absent keeps, a value replaces, {} deletes all.
  • Single-panel save() / restore(): the table field is now a TableRef, either a hosted table name or an inline derived-table definition recursing through its own table field. restore() reuses a structurally identical derived table or creates one under a generated name.
  • "Subqueries" stack in the settings sidebar and Derive Table in the panel context menu, if supported by the client's
    view_derivations feature. The "New" menu lists derived tables with reader counts and a delete action.

row_number window aggregate

  • New perspective-server window aggregate row_number: 1-based, dense position of the row in its partition's order_by order (already supported in DuckDB and Postgres Virtual Servers).
  • Declared in GetFeatures for every source type, so the window editor offers it after any column. ClickHouse virtual servers (TS and Python) now declare it too.

Internal

  • PSP_FAST=1: release build at -O1, no LTO, no wasm-opt. Cargo [profile.fast] and bundle --fast. pnpm run setup replaces the debug/fast confirms with one three-way "Build mode?" prompt so the two cannot coexist. I may try this with CI next.

Fixes

Example

Expression column on aggregates

{
        "plugin": "Datagrid",
        "table": {
            "table": "superstore",
            "group_by": ["State"],
            "group_rollup_mode": "flat",
            "columns": ["Sales", "Profit"],
            "aggregates": {
                "Profit": ["weighted mean", ["Row ID"]],
                "Sales": ["weighted mean", ["Postal Code"]]
            }
        },
        "title": "Superstore",
        "group_by": ["State"],
        "expressions": {
            "\"Sales\" - \"Profit\"": "\"Sales\" - \"Profit\""
        },
        "columns": ["Sales", "Profit", "\"Sales\" - \"Profit\""]
    }
Screenshot 2026-10-07 at 10 27 59 AM



Top 3 most recent orders

{
        "plugin": "Datagrid",
        "table": "superstore",
        "sort": [["Order Date", "desc"]],
        "filter": [["New Column 1", "<=", 3]],
        "windows": {
            "New Column 1": {
                "column": "Row ID",
                "aggregate": "row_number",
                "order_by": ["Order Date", "desc"]
            }
        },
        "columns": ["Sales", "Customer Name", "Order Date"]
    }
Screenshot 2026-10-07 at 8 34 43 PM

Signed-off-by: Andrew Stein <steinlink@gmail.com>
Signed-off-by: Andrew Stein <steinlink@gmail.com>
@texodus texodus added enhancement Feature requests or improvements breaking labels Oct 8, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking enhancement Feature requests or improvements

1 participant