Skip to content
Open
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
1 change: 1 addition & 0 deletions build/lib/stylelint/vscode-known-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@
"--vscode-positronModalDialog-buttonBorder",
"--vscode-positronModalDialog-buttonDestructiveBackground",
"--vscode-positronModalDialog-buttonDestructiveForeground",
"--vscode-positronModalDialog-buttonDestructiveHoverBackground",
"--vscode-positronModalDialog-buttonDisabledBackground",
"--vscode-positronModalDialog-buttonDisabledBorder",
"--vscode-positronModalDialog-buttonDisabledForeground",
Expand Down
12 changes: 8 additions & 4 deletions extensions/positron-data-driver-duckdb/src/duckdbConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ export class DuckDBConnection implements positron.DataConnection, IDuckDBPreview
/**
* Opens the given table or view in the Data Explorer. Registers a table view with the RPC
* handler under a stable per-connection dataset id, then asks Positron to open (or focus) the
* explorer backed by this extension's provider.
* explorer backed by this extension's provider. Returns the dataset id it was opened under, which
* Positron uses to tell that this connection has a Data Explorer open on it.
*/
async previewObject(schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<void> {
async previewObject(schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<string> {
this._ensureConnected();
const datasetId = `duckdbconn:${this._connectionId}:${kind}:${schemaName}.${tableName}`;
await this._dataExplorerHandler.openTableView(datasetId, this._lease!.client, schemaName, tableName, kind);
Expand All @@ -107,13 +108,15 @@ export class DuckDBConnection implements positron.DataConnection, IDuckDBPreview
datasetId,
displayName: tableName,
});
return datasetId;
}

/**
* Opens a single column of the given table or view in the Data Explorer as a one-column grid.
* Uses a dataset id distinct from the table's so both can be open at once.
* Uses a dataset id distinct from the table's so both can be open at once. Returns the dataset id
* it was opened under.
*/
async previewColumn(schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<void> {
async previewColumn(schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<string> {
this._ensureConnected();
const datasetId = `duckdbconn:${this._connectionId}:column:${schemaName}.${tableName}.${columnName}`;
await this._dataExplorerHandler.openColumnView(datasetId, this._lease!.client, schemaName, tableName, kind, columnName);
Expand All @@ -123,6 +126,7 @@ export class DuckDBConnection implements positron.DataConnection, IDuckDBPreview
datasetId,
displayName: `${tableName}.${columnName}`,
});
return datasetId;
}

/** Returns whether this connection was opened in read-only mode. */
Expand Down
8 changes: 4 additions & 4 deletions extensions/positron-data-driver-duckdb/src/duckdbNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { IDuckDBQueryClient } from 'positron-data-explorer-duckdb';
* DuckDBConnection, which owns the worker client and the dataset registration.
*/
export interface IDuckDBPreviewHost {
/** Opens the given table or view in the Data Explorer. */
previewObject(schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<void>;
/** Opens a single column of the given table or view in the Data Explorer. */
previewColumn(schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<void>;
/** Opens the given table or view in the Data Explorer, returning its dataset id. */
previewObject(schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<string>;
/** Opens a single column of the given table or view in the Data Explorer, returning its dataset id. */
previewColumn(schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<string>;
}

/**
Expand Down
7 changes: 6 additions & 1 deletion extensions/positron-data-driver-pins/src/pinsConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,12 @@ export class PinsConnection implements positron.DataConnection, IPinsBrowseHost
* its data file, downloads that file (reusing the cached copy when present), loads it into the
* DuckDB worker as a table, and opens the explorer over it. Convert-to-Code in the resulting
* explorer emits `pin_read` code rather than SQL against the throwaway table.
*
* Returns the dataset id the explorer was opened under, which Positron uses to tell that this
* connection has a Data Explorer open on it, or undefined when a disconnect raced the preview and
* nothing was opened.
*/
async previewPin(pin: PinInfo, bundleId: string, isActiveVersion: boolean): Promise<void> {
async previewPin(pin: PinInfo, bundleId: string, isActiveVersion: boolean): Promise<string | undefined> {
this._ensureConnected();

// Resolve the version's data file and confirm it is a previewable, single-file tabular type.
Expand Down Expand Up @@ -226,6 +230,7 @@ export class PinsConnection implements positron.DataConnection, IPinsBrowseHost

this._logger.info(`Opening ${displayName} in the Data Explorer`);
await positron.dataExplorer.open({ providerId: PINS_DATA_EXPLORER_PROVIDER_ID, datasetId, displayName });
return datasetId;
}

/** Marks the connection disconnected, releases previewed views, and closes the DuckDB worker. */
Expand Down
4 changes: 3 additions & 1 deletion extensions/positron-data-driver-pins/src/pinsNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ export interface IPinsBrowseHost {
* @param bundleId The bundle (version) id whose data to preview.
* @param isActiveVersion Whether `bundleId` is the pin's active version; the active version reads
* as the latest, so its generated code omits the explicit `version` argument.
* @returns The dataset id the explorer was opened under, or undefined when a disconnect raced the
* preview and nothing was opened.
*/
previewPin(pin: PinInfo, bundleId: string, isActiveVersion: boolean): Promise<void>;
previewPin(pin: PinInfo, bundleId: string, isActiveVersion: boolean): Promise<string | undefined>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,10 @@ export class PostgreSQLConnection implements positron.DataConnection, IPostgresC
* handler under a stable per-connection dataset id, then asks Positron to open (or focus) the
* explorer backed by this extension's provider. `client` is the client the object's node was built
* against and `database` is the database it lives in (undefined in single-database mode), so the
* dataset id and query client match the right database.
* dataset id and query client match the right database. Returns the dataset id it was opened
* under, which Positron uses to tell that this connection has a Data Explorer open on it.
*/
async previewObject(client: PostgreSQLClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<void> {
async previewObject(client: PostgreSQLClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<string> {
this._ensureConnected();
const datasetId = `postgresql:${this._connectionId}:${database ?? ''}:${kind}:${schemaName}.${tableName}`;
await this._dataExplorerHandler.openTableView(datasetId, this._queryClient(client), schemaName, tableName, kind);
Expand All @@ -323,13 +324,15 @@ export class PostgreSQLConnection implements positron.DataConnection, IPostgresC
datasetId,
displayName: tableName,
});
return datasetId;
}

/**
* Opens a single column of the given table or view in the Data Explorer as a one-column grid.
* Uses a dataset id distinct from the table's so both can be open at once.
* Uses a dataset id distinct from the table's so both can be open at once. Returns the dataset id
* it was opened under.
*/
async previewColumn(client: PostgreSQLClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<void> {
async previewColumn(client: PostgreSQLClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<string> {
this._ensureConnected();
const datasetId = `postgresql:${this._connectionId}:${database ?? ''}:column:${schemaName}.${tableName}.${columnName}`;
await this._dataExplorerHandler.openColumnView(datasetId, this._queryClient(client), schemaName, tableName, kind, columnName);
Expand All @@ -339,6 +342,7 @@ export class PostgreSQLConnection implements positron.DataConnection, IPostgresC
datasetId,
displayName: `${tableName}.${columnName}`,
});
return datasetId;
}

/** A query client over the given pg client, for the Data Explorer table views. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { PostgreSQLClient } from './postgresqlClient.js';
* so previewed datasets stay unique across databases.
*/
export interface IPostgresPreviewHost {
/** Opens the given table or view in the Data Explorer. */
previewObject(client: PostgreSQLClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<void>;
/** Opens a single column of the given table or view in the Data Explorer. */
previewColumn(client: PostgreSQLClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<void>;
/** Opens the given table or view in the Data Explorer, returning its dataset id. */
previewObject(client: PostgreSQLClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<string>;
/** Opens a single column of the given table or view in the Data Explorer, returning its dataset id. */
previewColumn(client: PostgreSQLClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<string>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const TEST_CONFIG: PostgreSQLConnectionConfig = {
// handler would register a vscode command that collides with the activated extension's. One object
// satisfies both the connection's host interface and the node-builder's preview-host interface.
const noopHost = {
previewObject: async () => { },
previewColumn: async () => { },
previewObject: async () => 'noop-dataset',
previewColumn: async () => 'noop-dataset',
openTableView: async () => { },
openColumnView: async () => { },
closeTableView: () => { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ export class RedshiftConnection implements positron.DataConnection, IRedshiftPre
/**
* Opens the given table or view in the Data Explorer. Registers a table view with the RPC handler
* under a stable per-connection dataset id, then asks Positron to open (or focus) the explorer
* backed by this extension's provider.
* backed by this extension's provider. Returns the dataset id it was opened under, which Positron
* uses to tell that this connection has a Data Explorer open on it.
*/
async previewObject(client: RedshiftClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<void> {
async previewObject(client: RedshiftClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<string> {
this._ensureConnected();
const datasetId = `redshift:${this._connectionId}:${database ?? ''}:${kind}:${schemaName}.${tableName}`;
await this._dataExplorerHandler.openTableView(datasetId, this._queryClient(client), database, schemaName, tableName, kind);
Expand All @@ -121,13 +122,15 @@ export class RedshiftConnection implements positron.DataConnection, IRedshiftPre
datasetId,
displayName: tableName,
});
return datasetId;
}

/**
* Opens a single column of the given table or view in the Data Explorer as a one-column grid.
* Uses a dataset id distinct from the table's so both can be open at once.
* Uses a dataset id distinct from the table's so both can be open at once. Returns the dataset id
* it was opened under.
*/
async previewColumn(client: RedshiftClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<void> {
async previewColumn(client: RedshiftClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<string> {
this._ensureConnected();
const datasetId = `redshift:${this._connectionId}:${database ?? ''}:column:${schemaName}.${tableName}.${columnName}`;
await this._dataExplorerHandler.openColumnView(datasetId, this._queryClient(client), database, schemaName, tableName, kind, columnName);
Expand All @@ -137,6 +140,7 @@ export class RedshiftConnection implements positron.DataConnection, IRedshiftPre
datasetId,
displayName: `${tableName}.${columnName}`,
});
return datasetId;
}

/** A query client over the given pg client, for the Data Explorer table views. */
Expand Down
8 changes: 4 additions & 4 deletions extensions/positron-data-driver-redshift/src/redshiftNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ const SYSTEM_SCHEMAS_SQL = SYSTEM_SCHEMAS.map(s => `'${s}'`).join(', ');
* database in single-database mode), so cross-database previews use a three-part reference.
*/
export interface IRedshiftPreviewHost {
/** Opens the given table or view in the Data Explorer. */
previewObject(client: RedshiftClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<void>;
/** Opens a single column of the given table or view in the Data Explorer. */
previewColumn(client: RedshiftClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<void>;
/** Opens the given table or view in the Data Explorer, returning its dataset id. */
previewObject(client: RedshiftClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<string>;
/** Opens a single column of the given table or view in the Data Explorer, returning its dataset id. */
previewColumn(client: RedshiftClient, database: string | undefined, schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<string>;
}

// --- Single-database family (connected database, information_schema) ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const TEST_CONFIG: RedshiftConnectionConfig = {
// handler would register a vscode command that collides with the activated extension's. One object
// satisfies both the connection's host interface and the node-builder's preview-host interface.
const noopHost = {
previewObject: async () => { },
previewColumn: async () => { },
previewObject: async () => 'noop-dataset',
previewColumn: async () => 'noop-dataset',
openTableView: async () => { },
openColumnView: async () => { },
closeTableView: () => { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ export class SnowflakeConnection implements positron.DataConnection, ISnowflakeP
/**
* Opens the given table or view in the Data Explorer. Registers a table view with the RPC handler
* under a stable per-connection dataset id, then asks Positron to open (or focus) the explorer
* backed by this extension's provider.
* backed by this extension's provider. Returns the dataset id it was opened under, which Positron
* uses to tell that this connection has a Data Explorer open on it.
*/
async previewObject(client: SnowflakeClient, database: string, schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<void> {
async previewObject(client: SnowflakeClient, database: string, schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<string> {
this._ensureConnected();
const datasetId = datasetKey(this._connectionId, kind, database, schemaName, tableName);
await this._dataExplorerHandler.openTableView(datasetId, this._queryClient(client), database, schemaName, tableName, kind);
Expand All @@ -97,13 +98,15 @@ export class SnowflakeConnection implements positron.DataConnection, ISnowflakeP
datasetId,
displayName: tableName,
});
return datasetId;
}

/**
* Opens a single column of the given table or view in the Data Explorer as a one-column grid.
* Uses a dataset id distinct from the table's so both can be open at once.
* Uses a dataset id distinct from the table's so both can be open at once. Returns the dataset id
* it was opened under.
*/
async previewColumn(client: SnowflakeClient, database: string, schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<void> {
async previewColumn(client: SnowflakeClient, database: string, schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<string> {
this._ensureConnected();
const datasetId = datasetKey(this._connectionId, 'column', database, schemaName, tableName, columnName);
await this._dataExplorerHandler.openColumnView(datasetId, this._queryClient(client), database, schemaName, tableName, kind, columnName);
Expand All @@ -113,6 +116,7 @@ export class SnowflakeConnection implements positron.DataConnection, ISnowflakeP
datasetId,
displayName: `${tableName}.${columnName}`,
});
return datasetId;
}

/** A query client over the given sdk client, for the Data Explorer table views. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ function schemaRef(database: string, schemaName: string): string {
* against; `database` is the database the object lives in, so previews use a three-part reference.
*/
export interface ISnowflakePreviewHost {
/** Opens the given table or view in the Data Explorer. */
previewObject(client: SnowflakeClient, database: string, schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<void>;
/** Opens a single column of the given table or view in the Data Explorer. */
previewColumn(client: SnowflakeClient, database: string, schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<void>;
/** Opens the given table or view in the Data Explorer, returning its dataset id. */
previewObject(client: SnowflakeClient, database: string, schemaName: string, tableName: string, kind: 'table' | 'view'): Promise<string>;
/** Opens a single column of the given table or view in the Data Explorer, returning its dataset id. */
previewColumn(client: SnowflakeClient, database: string, schemaName: string, tableName: string, kind: 'table' | 'view', columnName: string): Promise<string>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const TEST_CONFIG: SnowflakeConnectionConfig = {
// handler would register a vscode command that collides with the activated extension's. One object
// satisfies both the connection's host interface and the node-builder's preview-host interface.
const noopHost = {
previewObject: async () => { },
previewColumn: async () => { },
previewObject: async () => 'noop-dataset',
previewColumn: async () => 'noop-dataset',
openTableView: async () => { },
openColumnView: async () => { },
closeTableView: () => { },
Expand Down Expand Up @@ -353,7 +353,7 @@ suite('Snowflake Driver Tests', () => {
// building the node through createSchemaNode must carry the database, schema, name, and kind
// through to previewObject.
const calls: unknown[][] = [];
const recordingHost = { ...noopHost, previewObject: async (...args: unknown[]) => { calls.push(args); } };
const recordingHost = { ...noopHost, previewObject: async (...args: unknown[]) => { calls.push(args); return 'noop-dataset'; } };

const schemaNode = createSchemaNode(mock, recordingHost, 'ANALYTICS', 'PUBLIC');
const tables = await tablesOf(schemaNode);
Expand Down
Loading
Loading