Skip to content

feat(dag-viewer): plan SQL queries over declared tables in the editor - #618

Draft
zzylol wants to merge 1 commit into
stack/fix-sql-count-sketchesfrom
stack/editor-sql
Draft

zzylol wants to merge 1 commit into
stack/fix-sql-count-sketchesfrom
stack/editor-sql

Conversation

@zzylol

@zzylol zzylol commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Stack: #574 → #620 → #618 → #621 → #627 → #625 → #628 → #632 → #634 → #616 → #617 → #622 → #624 → #629 → #630 → #631 → #633 → #635 → #636 → #637

Problem

The query editor and stage_pipeline only planned PromQL; SQL needed a catalog, and the only SQL workload was Example 2's hard-wired flows table (Q54).

Changes

  • stage_pipeline: repeatable --sql <query> and --table '<json>' ({"name", "columns": [{"name", "type": timestamp|utf8|string|float64|double|int64|bigint, "nullable" (default true)}], "time_index"?}; same semantics as dag_export's --table-schema, no default tables). A run is one language: mixing --promql and --sql is an error, as is --table without --sql; malformed tables, duplicate names and out-of-range time_index are errors, not panics. --epsilon/--delta/--interval-ms apply as for PromQL. Example 2's flows now goes through the same catalog code (its fixture output is unchanged). Header comment and USAGE updated.
  • server.py: plan_args accepts language (promql|sql) and tables; validates 1–20 queries, ≤50 tables, 1–500 columns, non-empty and unique names, known types, time_index; passes --table <json>/--sql.
  • Editor: PromQL/SQL switch (each language keeps its own draft), a "tables (JSON, one table per line)" box prefilled with flows, example query SELECT COUNT(DISTINCT src_ip) FROM flows; existing CSS tokens.
  • The test helper's temp file name no longer embeds the arguments (a --table JSON made it too long).
  • README editor section updated.

Test plan

  • cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings
  • cargo test -p asap-devtools: 47 passed (new: SQL over a --table writes a valid document with language "sql"; mixing languages, --table without --sql, bad table JSON, duplicate tables and undeclared tables error)
  • cargo test --workspace: 1673 passed, 0 failed, 21 ignored (re-run after the rebase on main d4869a7)
  • Viewer tests (python3 -m unittest test_viewer with py_mini_racer): 26 passed, none skipped (new ServerTests for SQL args and validation)
  • Smoke test: server.py --port 8790 --skip-build, POSTed a SQL request over flows → 200 with a valid asap-stage-pipeline/v1 document (language "sql", 5 physical candidates, P1 selected); a bad column type → 400 with a clear message

🤖 Generated with Claude Code

stage_pipeline takes repeatable --sql and --table '<json>' (compact
schema: name, columns with type and nullable, optional time_index); a run
is one language. Example 2's flows table goes through the same catalog
code. server.py validates and forwards SQL requests, and the query editor
gets a PromQL/SQL switch with a tables box.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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