Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions src/Client/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Kusto Explorer (VS Code Extension)

Edit, run and chart Kusto queries (KQL).
Explore databases and query results.
- Edit, run and chart Kusto queries (KQL)
- Explore databases and query results
- Consult copilot to help create, run and diagnose your queries

## Get Started
- Open or create a `.kql` file in VS Code
Expand All @@ -14,6 +15,11 @@ Explore databases and query results.
- Add another query to the kql document, rinse and repeat
- Save your results and charts as a .kqr file to share with others or re-open later

## Kusto Connections (in explorer panel)
- Keep a list of Kusto servers you use to run queries
- Select a server and database to be the default database for your query document
- Explore the entities available in each database

## Query Editor (.kql documents)
- Syntax and semantic coloring of query text
- Autocompletion (Intellisense)
Expand All @@ -22,19 +28,25 @@ Explore databases and query results.
- Goto definition and find all references for functions, tables, columns, and more
- Code actions and quick fixes for common issues and refactorings
- Copy colorized query text to the clipboard for pasting into other documents
- Have mutliple independent queries in the same document, separated by a blank line.
- Have multiple independent queries in the same document, separated by a blank line.

## Results Panel (bottom panel)
- Copy contents of cells or entire table to clipboard
- Drag and drop a table into your document as a KQL datatable expression
- Drag and drop a table into your document as a KQL `datatable` expression
- Chart your data (it will open in a results viewer tab)
- Save the data as a `.kqr` file (Kusto Query Results)

## Chart Panel (with documents)
- Edit the chart options to customize the chart type, axes, legend and more
- Copy the chart as an image to clipboard for either light-mode or dark-mode pasting
- Save chart and data as a `.kqr` file (Kusto Query Result)

## Results Viewer (.kqr documents)
- Shows both result data and chart in the same view
- Copy the chart as an image to clipboard for either light-mode or dark-mode pasting.
- Copy the data to clipboard just like results panel.
- Shows chart, data and query in one view
- Add a chart if you don't have one yet
- Edit the chart options to customize the chart type, axes, legend and more
- Save to a .kqr file to share with others or re-open later
- Copy the chart as an image to clipboard for either light-mode or dark-mode pasting
- Copy the data to clipboard just like results panel

## Requirements
- VS Code 1.9.0 or higher
4 changes: 2 additions & 2 deletions src/Client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as vscode from 'vscode';
import { workspace, ExtensionContext, window } from 'vscode';
import * as conn from './features/connectionsPanel'
import * as connections from './features/connections'
import * as documentPanels from './features/documentPanels'
import * as queryDocuments from './features/queryDocuments'
import * as resultsViewer from './features/resultsViewer'
import * as copilot from './features/copilot'
import * as connectionStatusBar from './features/connectionStatusBar'
Expand Down Expand Up @@ -131,7 +131,7 @@ export async function activate(context: ExtensionContext)
connectionStatusBar.activate(context);

// activate query execution features
documentPanels.activate(context, client);
queryDocuments.activate(context, client);

// activate chart file editor (.kchart)
resultsViewer.activate(context, client);
Expand Down
6 changes: 2 additions & 4 deletions src/Client/features/copilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import * as conn from './connections';
import * as server from './server';
import { ENTITY_DEFINITION_SCHEME } from './entityDefinitionProvider';
import { resultTableToMarkdown } from './markdown';
import * as resultsPanel from './resultsPanel';
import { displayChart } from './resultsViewer';
import { displayResultsPanel, displaySingletonResultView, ResultViewMode } from './resultsViewer';

const COPILOT_PARTICIPANT_ID = 'kusto';
const MAX_SCHEMA_CHARS = 30000; // Approximate limit to stay within token limits
Expand Down Expand Up @@ -412,8 +411,7 @@ async function runQuery(input: { query: string; cluster?: string; database?: str
}

if (input.showResults) {
await resultsPanel.displayResults(languageClient, result.data);
await displayChart(languageClient, result.data);
await displaySingletonResultView(languageClient, result.data, 'all', true);
}

return resultTableToMarkdown(result.data.tables[0]!);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import * as vscode from 'vscode';
import { LanguageClient } from 'vscode-languageclient/node';
import { setDocumentConnection, ensureServer, getDocumentConnection } from './connections';
import * as server from './server';
import * as resultsPanel from './resultsPanel';
import { displayChart } from './resultsViewer';
import { displayResultsPanel, displayError, displaySingletonResultView, ResultViewMode } from './resultsViewer';
import * as resultsCache from './resultsCache';
import { getClipboardContext, clearClipboardContext, copyToClipboard } from './clipboard';
import { ENTITY_DEFINITION_SCHEME } from './entityDefinitionProvider';
Expand All @@ -29,9 +28,6 @@ let codeLensProvider: KustoCodeLensProvider;
*/
export function activate(context: vscode.ExtensionContext, client: LanguageClient): void {

// Activate results panel
resultsPanel.activate(context, client);

// Register query-related commands
context.subscriptions.push(
vscode.commands.registerCommand('kusto.runQuery', (startLine?: number, startChar?: number, endLine?: number, endChar?: number) => runQuery(client, rangeFromArgs(startLine, startChar, endLine, endChar))),
Expand Down Expand Up @@ -143,8 +139,7 @@ async function runQuery(client: LanguageClient, queryRange?: server.SelectionRan
if (runResult && runResult.error)
{
// display error and highlight error range
await resultsPanel.displayError(runResult.error);
await displayChart(client, undefined);
await displayError(runResult.error);

if (runResult.error.range) {
const r = runResult.error.range;
Expand All @@ -158,8 +153,8 @@ async function runQuery(client: LanguageClient, queryRange?: server.SelectionRan
await resultsCache.addToCache(uri, queryText, runResult.data);

// Display result tables and chart from ResultData
await resultsPanel.displayResults(client, runResult.data);
await displayChart(client, runResult.data);
await displayResultsPanel(client, runResult.data, 'data');
await displaySingletonResultView(client, runResult.data, 'chart', true);
}

// Refresh CodeLens to show/hide Results lens
Expand Down Expand Up @@ -197,8 +192,8 @@ async function showResults(client: LanguageClient, uri: string, line: number, ch
));
const cachedData = await resultsCache.getFromCache(uri, queryText);
if (cachedData) {
await resultsPanel.displayResults(client, cachedData);
await displayChart(client, cachedData);
await displayResultsPanel(client, cachedData, 'data');
await displaySingletonResultView(client, cachedData, 'chart', true);
}
} catch (error) {
vscode.window.showErrorMessage(`Failed to show results: ${error}`);
Expand Down
Loading
Loading