DynoTable for Sublime Text

The LSP-dynotable package lets you write SQL, PartiQL and OpenSearch queries in Sublime Text and run them against the tables and indices of a DynoTable profile.

The DynoTable desktop app on the same computer serves the language features from your real schemas and runs the queries. The query files and the language are the same as in DynoTable for VS Code.

What you need

  • Sublime Text, build 4200 or later.
  • macOS (Apple silicon or Intel), Linux x64 or Windows x64.
  • DynoTable 1.20.0 or later, installed on the same computer.
  • Editor integration switched on in the app. It is off by default.

The package uses dynotable-lsp from your PATH. When dynotable-lsp is not on your PATH, the package installs the dynotable-cli version that it pins. It runs it with Node.js from your PATH, or with a Node.js that it downloads. See Install dynotable-cli.

Turn on Editor integration

  1. Open DynoTable.
  2. Go to Settings → Editor integration.
  3. Switch on Editor integration.

You do this one time. Start DynoTable before you open a query file. When DynoTable is not running, the file gets no language features: start DynoTable, then switch to the file. To let the package start DynoTable with no window instead, set "launch_app": true in Preferences → Package Settings → LSP-dynotable.

Install the package

  1. Install Package Control.
  2. Open the Command Palette, run Package Control: Install Package and pick LSP.
  3. Run Package Control: Install Package again and pick LSP-dynotable.

Query files

FileLanguage
*.dtsqlDynoTable SQL, over tables and indices
*.dynotable.sqlDynoTable SQL, over tables and indices
*.partiqlDynamoDB PartiQL
*.opensearchOne OpenSearch query: JSON query DSL or Lucene

The package does not attach to plain .sql or .json files. To query DynoTable from a .sql file, rename it to *.dynotable.sql.

An OpenSearch file names its index on its first line:

// dynotable: index=orders
{"match": {"status": "shipped"}}

Pick a profile

A connection uses one DynoTable profile. To pick it, put a .dynotable.json file in the root of your project:

{"profile": "dev"}

The value is a profile id or slug. With no .dynotable.json, DynoTable uses your profile when you have exactly one.

What the package does

  • Completion from your real table schemas and index mappings.
  • Diagnostics.
  • Hover.
  • Formatting.
  • Rename of table aliases.
  • Inlay hints, when you switch them on. Set "show_inlay_hints": true in the LSP settings, or run LSP: Toggle Inlay Hints.
  • A Run lens above each SQL and PartiQL statement. A statement can also get an Open in DynoTable lens, which opens the statement's table in the app.

Run a statement

Click the Run lens above a statement, or run DynoTable: Run Statement from the Command Palette. The command runs the selection. With no selection, it runs the statement at the cursor. In an OpenSearch file, it runs the whole file.

OpenSearch files get no lenses. Use DynoTable: Run Statement. Use the command also when the lens is cut off at the end of a long line.

The rows show in the DynoTable Results panel at the bottom of the window, with a summary line under the table.

You can run one statement at a time in a window. DynoTable: Run Statement runs your unsaved edits as you see them.

Work with the results

  • DynoTable: Sort Results sorts the rows in the panel by a column that you pick, ascending or descending. Text sorts by code point, so a few rare characters can sort in a different order than in VS Code.
  • DynoTable: Copy Results as CSV, … as JSON and … as Markdown copy all rows in query order, also after a sort.
  • DynoTable: Cancel Run stops the run. The panel says that the run was cancelled.

Add a key binding for Run

The package has no key binding for Run, because ⌘↩ and Ctrl+Enter are core keys of Sublime Text. To add one, run Preferences: Key Bindings and add:

{
  "keys": ["super+enter"],
  "command": "dynotable_run",
  "context": [
    {"key": "selector", "operand": "source.sql.dynotable | source.partiql | source.opensearch"}
  ]
}

Use ctrl+enter on Linux and Windows. The context keeps the core key in all other files.

Writes go through the app

DynoTable SQL is read-only, as in the SQL Workbench.

A PartiQL write does not run from the editor. Make writes in DynoTable, where staging holds the change for review.

What runs on your plan

The package is free. What runs depends on your DynoTable license, as in the app:

  • Free (signed in): completion, diagnostics, PartiQL SELECT statements and OpenSearch queries.
  • Trial or paid: running SQL statements, as in the SQL Workbench. This includes SQL over an OpenSearch index and a JOIN of a DynamoDB table to an OpenSearch index.
  • Signed out: nothing. Sign in to DynoTable.

See Activation for the license states.

What does not work

  • Plain .sql and .json files. The package attaches only to the query files.
  • PartiQL writes. Make them in DynoTable.
  • Lenses in OpenSearch files. Use DynoTable: Run Statement.
  • A lens that you click right after an edit can run the wrong text. Use DynoTable: Run Statement then.
  • A file with a syntax error has no statements to run.
  • Two runs at the same time in one window.
  • Platforms other than macOS, Linux x64 and Windows x64. dynotable-lsp has no binary for them yet.

After you quit DynoTable

The language server stops and stays stopped. The package does not start DynoTable again. To get the features back:

  1. Start DynoTable.
  2. Switch to a DynoTable file, or open one.

When DynoTable refuses the connection

DynoTable refuses the connection when:

  • you are signed out;
  • the Editor integration is off;
  • the .dynotable.json of the project is not correct.

The status bar then says "DynoTable refused the connection", and the console (View → Show Console) gives the reason. The language server stays stopped in that window. Other windows keep their language server.

Fix the cause, then run DynoTable: Retry Connection from the Command Palette in that window.

The package's source is on GitHub under the MIT license.

Updated