← Back to Pull requests

feat: Web console: highlight NULLS FIRST / NULLS LAST and upgrade druid-query-toolkit to 1.7.0 #20621

Closed
unknown closed this pull request without merging on Oct 19, 2026 22:17 UTC
View on GitHub
unknown unknown commented on Oct 16, 2026 23:04 UTC
Author

Summary

<img width="532" height="146" alt="image" src="https://github.com/user-attachments/assets/6d5a7eed-fae7-457d-8723-82b63f4fbcf3" />

Three web console changes.

1. NULLS FIRST / NULLS LAST in the SQL editor. These clauses already worked in Druid, but the editor showed NULLS and LAST as plain identifiers. Both are now keywords, so they are highlighted and autocompleted:

 ORDER BY 2 DESC
-  (no keyword suggestions after DESC)
+  suggests NULLS
+  NULLS → suggests FIRST, LAST

Keyword suggestions can now also depend on the two keywords before the cursor, and a matching pair wins over the single keyword. Before, a keyword got the same suggestions everywhere. That made NULLS FIRST suggest ROW / ROWS (meant for FETCH FIRST), and had similar problems elsewhere:

| After | Before | Now |
|---|---|---|
| NULLS FIRST | ROW ROWS | nothing |
| GROUP BY | GROUPING ROLLUP CUBE ALL HOUR DAY MONTH YEAR | GROUPING ROLLUP CUBE |
| PARTITIONED BY | (same 8) | ALL HOUR DAY MONTH YEAR |
| ORDER BY, PARTITION BY, CLUSTERED BY | (same 8) | nothing |
| SELECT ALL | TIME | nothing |
| UNION ALL | TIME | SELECT |
| SELECT DISTINCT, COUNT(DISTINCT | FROM | nothing |
| IS NOT | every keyword | DISTINCT |
| LEFT/RIGHT/FULL OUTER | every keyword | JOIN |
| CURRENT ROW | ONLY | nothing |
| EXPLAIN PLAN FOR | every keyword | SELECT INSERT REPLACE |

FETCH FIRST → ROW ROWS, PARTITIONED BY ALL → TIME and IS [NOT] DISTINCT → FROM are unchanged.

2. druid-query-toolkit 1.2.2 → 1.7.0. The toolkit now uses SqlQueryBase as the common query type, so the console accepts it wherever any query form is fine:

-parseSqlQuery(): SqlQuery | undefined        // only SELECT / WITH
+parseSqlQuery(): SqlQueryBase | undefined    // any query form, WITH flattened

cell-filter-menu, preview-table and result-table-pane now take SqlQueryBase. grouping-table-module narrows with instanceof SqlQuery before calling changeWhereExpression.

3. Line numbers duplicating in the workbench editor. In a query like … ORDER BY 2 DESC, typing N and deleting it again (repeatedly) turned the line number 1 into 11, 111, and so on. Typing N makes the text parse only as a sub query, which adds a "run this query" button to line 1; deleting it removes the button. CodeMirror's gutter removes one node per marker, but SubQueryMarker.toDOM returned a fragment of two nodes (the button and the line number), so the line number text was left behind each time:

 SubQueryMarker.toDOM()
-  fragment(button, "1")
+  span(button, "1")

The code-editor README now notes that a gutter marker's toDOM must return a single node.

Supporting changes for the toolkit upgrade:

  • tsconfig.json: adds "node" to types. The 1.2.2 typings had a /// <reference types="node" /> that leaked Node globals into the whole project, and the tests and e2e code depended on it without saying so.

  • package.json: adds an overrides entry so @istanbuljs/load-nyc-config uses js-yaml@^4. This removes sprintf-js, which has an advisory and no fixed release. That package only calls js-yaml.load, which still exists in v4.
  • Evidence

  • Highlighting: a new test in editor-languages.spec.ts tokenizes ORDER BY 2 DESC NULLS LAST, 1 NULLS FIRST. NULLS, LAST and FIRST come out as Keyword; before this change, NULLS and LAST were Identifier.

  • Completion: new tests in sql-completions.spec.ts check the suggestions: … DESC | → [NULLS], … DESC NULLS | → [FIRST, LAST], and … NULLS LAST | / … NULLS FIRST | → []. They also check every row of the table above, plus the unchanged cases.

  • Line numbers: a new test in sub-query-markers.spec.ts types N and deletes it three times in a real EditorView, checking the line-1 number each time. Before the fix it read 11; now it reads 1.

  • Checks: npm run test-base (eslint, sasslint, prettier, jest) passes, with 856 tests. tsc --noEmit and the production webpack build (npm run compile) also pass.

  • npm audit: down from 26 issues to 7. All 7 remaining issues come from braces (via stylelint and webpack-dev-server, both dev-only), and braces has no fixed version yet.
  • Merge Danger

    Door: two-way

    Blast Radius: web-console

    The changes are limited to the console's SQL editor and query-model typing, plus dev-only dependency resolution. Moving to toolkit 1.7.0 also changes SQL parsing and printing throughout the console (explore view, workbench, SQL data loader). The unit tests cover this, but the e2e suite was not run.

    Release note

    The web console's SQL editor now highlights and autocompletes NULLS FIRST / NULLS LAST, and its keyword suggestions take the previous keyword into account (for example GROUP BY vs ORDER BY). Also fixes line numbers in the workbench editor duplicating while typing.

    🤖 Generated with Claude Code

    Diff: 629 lines (+471 / -158) across 7 files Reviewer: gianm Review duration: 4273m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.55) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 629 lines diff across 7 files
    0.55
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.386
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #20621"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 55.4% (MEDIUM) · Higher = larger blast radius
    55.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.9% · Safe to merge
    23.9%
    Repository