Visual Studio Code extension for Treasure Data

In the world of data analysis and manipulation, having the right tools at your disposal can make a significant difference in your productivity and efficiency. One such tool that deserves attention is the TD Query Tool (TDQT) extension for Visual Studio Code. This powerful extension empowers data professionals to perform complex queries and analyses within the familiar environment of VS Code.

Setup

  1. In the Extensions Marketplace, search for Treasure Data and find the Treasure Data Query Tool extension. Click on the "Install" button to install the extension.
  2. After installation, go back to the Command Palette and search for TDQT Select API Host . Select this command and choose the desired endpoint from the available options.
  3. Next, go to the Command Palette again and search for TDQT Add APIKEY . Select this command and enter your Treasure Data master API key when prompted.

Use

TDQT provides browsing and querying capabilities across your databases.

Browsing Databases, Tables and Saved Queries

  1. After installing the extension, you will see the Treasure Data sidebar icon. Click on it to reveal the list of databases, tables, and saved queries.
  2. Right-click on a database to access the following options:
    • Copy Database Name and Table Name - Copies the names of the selected database and table for later use.
    • Select Top 100 - Executes a query to select the top 100 rows from the table and displays the results.
    • Show Table Schema - Shows the schema of the selected table.
  3. When expanding a database tree, the table schema will be displayed. Right-clicking on a column in the schema allows you to copy the column name for use in queries.
  4. The Queries list displays saved queries that you can open in the editor.

menu

Running Queries

  1. To run a query, open a blank editor window or select a previously saved query.
  2. Use the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and search for TDQT: Run Query . Select this command to start a new job on Treasure Data with the query from the current window.
  3. An output window will show the progress of the job as it runs on the Treasure Data service.
  4. Once the job is completed, another window will appear displaying the output of the query. You can inspect and analyze the results directly in the Visual Studio Code environment.

result

VS Code ecosystem

VS Code has a lot of great extensions that allow you to write SQL effectively. A combination of these extensions can help your day to day SQL life!

Here is some useful extensions I like!

  • Prettier SQL VSCode : Formats SQL files using the sql-formatter library
  • sqlfluff : A linter and auto-formatter for SQLFluff, a popular linting tool for SQL and dbt.

Appendix: Supported Commands

command

Expand this section for a full list of supported commands in the Command Pallet.
  • td-query-tool.runQuery
    • TDQT: Run Query editor/title
  • td-query-tool.showTableSchema
    • Show Table Schema
  • td-query-tool.openQuery
    • TDQT: Open Query
  • td-query-tool.selectQuery
    • TDQT: Select and Open Query
  • td-query-tool.validateQuery
    • TDQT: Validate Query
  • td-query-tool.setQueryEngine
    • TDQT: Select Query Engine
  • td-query-tool.refreshDatabases
    • Refresh commandPaletteview/title
  • td-query-tool.refreshQueries
    • Refresh commandPaletteview/title
  • td-query-tool.copyDatabaseName
    • Copy Database Name
  • td-query-tool.copyTableName
    • Copy Database and Table Name
  • td-query-tool.copyColumnName
    • Copy Column Name
  • td-query-tool.addPreset
    • TDQT: Add Preset
  • td-query-tool.selectPreset
    • TDQT: Select Preset
  • td-query-tool.deletePreset
    • TDQT: Delete Preset
  • td-query-tool.updatePreset
    • TDQT: Update Preset
  • td-query-tool.saveQuery
    • TDQT: Save Query
  • td-query-tool.selectTop100
    • Select Top 100
  • td-query-tool.showJobsHistory
    • TDQT: Show Jobs History
  • Set the API host via the command palette
    • TDQT: Select API Host Domain
  • Set the API Key via the command palette
    • TDQT: Add API Key. Add an API key with Read permissions on the account.

Latest from our blog

Upcoming Evolution of Treasure Data Query Engines

Journey to Containers in Core Services Worker Platform

Sharing our journey with container technology from Worker Platform that manages the fair scheduling of jobs and helps manage the state of individual jobs.

Automatic Customer Segmentation with Machine Learning

Making Your Auto-Segmentation Model Work For You