Skip to content

SQL Query Runner Page #300

@ElioNeto

Description

@ElioNeto

SQL Query Runner Page

Create an Angular page that provides an interactive SQL query interface using the existing SqlEngine.

Backend Endpoints Needed

POST /admin/sql/query        — Execute a SQL query and return results
                              Body: { "sql": "SELECT * FROM default" }
                              Response: { "columns": [...], "data": [...], "affected": N }
POST /admin/sql/explain      — Explain query plan (without executing)
                              Body: { "sql": "SELECT * FROM default" }
POST /admin/sql/validate     — Validate SQL syntax (without executing)

UI Requirements

Query Editor

  • Code Editor: Multi-line textarea with SQL syntax highlighting (CodeMirror or Monaco)
  • Execute Button: Run query with keyboard shortcut (Ctrl+Enter)
  • Explain Button: Show query plan without executing
  • History: Dropdown of recent queries
  • Templates: Quick insert templates (SELECT, INSERT, DELETE, etc.)

Results Display

  • Table: Column headers + data rows
  • Pagination: If many results, paginated view
  • Export: Download results as CSV/JSON
  • Row Count: Display total rows returned
  • Execution Time: Display query duration

Error Display

  • Error Message: Clear, formatted SQL error
  • Line Highlight: Highlight error location if available
  • Suggestions: Common fixes for known errors

Supported SQL Statements

  • SELECT * FROM <cf> — Scan all keys
  • SELECT * FROM <cf> WHERE key = '<k>' — Get specific key
  • INSERT INTO <cf> (key, value) VALUES ('k', 'v') — Insert/update
  • DELETE FROM <cf> WHERE key = '<k>' — Delete key
  • SELECT COUNT(*) FROM <cf> — Count keys

Component Structure

app/
  pages/
    sql-runner/
      sql-runner.component.ts
      sql-runner.component.html
      sql-runner.component.scss

Acceptance Criteria

  • SQL editor accepts input and executes on Ctrl+Enter
  • Results display in table format
  • Error messages are human-readable
  • Query history accessible
  • Export to CSV works
  • Explain shows query plan
  • Loading state during execution
  • Responsive layout

Parent Epic

#290

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions